-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Editor store: remove createUndoLevel and refreshPost actions #38585
Conversation
Size Change: -48 B (0%) Total Size: 1.14 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find @jsnajdr!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the functions with a deprecated
call (and remove their content) instead for some versions to avoid creating JS errors for potential plugins using them even if they don't do anything?
0f95628
to
f6c3fd6
Compare
Yes I changed the patch to make the action creators empty (returning a One thing I'm not sure about is how to express the "deprecated since" versions. Since WordPress 5.9? Since Gutenberg 13.0.0? Both versioning lines seem to be used. |
I think it should be |
We use Gutenberg version only for things that didn't make it yet to WordPress. |
Pushed a commit that clarifies the versions: deprecated in 6.0, removed in 6.3. |
return { type: 'CREATE_UNDO_LEVEL' }; | ||
deprecated( "wp.data.dispatch( 'core/editor' ).createUndoLevel", { | ||
since: '5.9', | ||
alternative: 'Use the core entities store instead', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is GitHub missing a commit or something, I don't see the "version": "6.0"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, turns out I didn't really push the commit to the server 🙂 Please look again now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
This PR removes two
editor
store actions that are unused. Even if someone tried to use them, they would discover they don't do anything useful at all.createUndoLevel
was gradually moved to thecore
store (especially in #13088), and today theeditor
reducer doesn't react to theCREATE_UNDO_LEVEL
action at all.refreshPost
used to be used in thePostPermalink
component, but that one was removed in #21099. The action used to fetch the latest version of the post from REST API, and store it in state withresetPost
. But today theresetPost
action resets just theid
andtype
fields, which are kind of guaranteed to never change.In short, gradual and mechanical refactorings removed all meaning from these two actions. Regarding backward compatibility, can we safely remove them? Given that the Gutenberg codebase doesn't use them, and anyone else doesn't have any reason to call them?
Discovered this when refreshing #35929, my PR to migrate the
editor
store to thunks.