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 after 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.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
saveEditedEntityRecorddoes not always save the entity record, meaning that bothsaveEditedEntityRecordandsaveEntityRecordneed to be called in order to save an entity record successfully.Taking a quick look at the
saveEditedEntityRecordfunction, it does callsaveEntityRecord, but there are some cases where I believe it's returning early unnecessarily, meaningsaveEntityRecordneeds to be specifically called. I think it's whenrecordIdisundefined, 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:The site settings will not be saved. However, if you run
saveEntityRecordimmediately after it, the site settings will be saved successfully:Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.