-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the bug
If the preferences of a user saved in localstorage ( key WP_DATA_USER_${USER_ID} ) includes an empty object ( { 'core/editor': { preferences: {} } ) this will cause the entire editor to crash when the getInsertUsage selector is used. Which is automatically within several seconds after starting when getInserterItems is called.
I've run into this issue on two separate installations now running WordPress 5.1.1 without the Gutenberg plugin installed. I've not yet found what exactly is causing preferences to be saved as an empty object but I believe it's likely related to https://github.com/WordPress/gutenberg/blob/master/packages/data/src/plugins/persistence/index.js#L210 as insertUsage is explicitly omitted there.
To Reproduce
Steps to reproduce the behavior:
- Somehow get a localStorage where under
WP_DATA_USER_${USER_ID}thecore/editorobject and thenpreferencesobject does not include aninsertUsagekey. - Open Gutenberg.
- Wait several seconds or call
wp.data.select( 'core/editor' ).getInserterItems() - See error
Expected behavior
Gutenberg not to crash and invalid values in localStorage to either be fixed or discarded.
Desktop (please complete the following information):
- OS: iOS
- Browser chrome
- Version 72.0.3626.121
