Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveEditedEntityRecord does not always save the entity record #67161

Open
2 of 6 tasks
mikachan opened this issue Nov 20, 2024 · 0 comments
Open
2 of 6 tasks

saveEditedEntityRecord does not always save the entity record #67161

mikachan opened this issue Nov 20, 2024 · 0 comments
Labels
[Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended

Comments

@mikachan
Copy link
Member

mikachan commented Nov 20, 2024

Description

saveEditedEntityRecord does not always save the entity record, meaning that both saveEditedEntityRecord and saveEntityRecord need to be called in order to save an entity record successfully.

Taking a quick look at the saveEditedEntityRecord function, it does call saveEntityRecord, but there are some cases where I believe it's returning early unnecessarily, meaning saveEntityRecord needs to be specifically called. I think it's when recordId is undefined, which it will be if saving global site settings which do not require an ID.

This came up while working on #65426.

Step-by-step reproduction instructions

Try saving the global site settings via saveEditedEntityRecord:

saveEditedEntityRecord( 'root', 'site', undefined, {
    page_on_front: item.id,
    show_on_front: 'page',
} );

The site settings will not be saved. However, if you run saveEntityRecord immediately before it, the site settings will be saved successfully:

saveEntityRecord( 'root', 'site', {
    page_on_front: [page id],
    show_on_front: 'page',
} );

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@mikachan mikachan added [Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

1 participant