-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Remove wp.data plugin support #12004
Remove wp.data plugin support #12004
Conversation
This is a great start, let's try to remove the persistence plugin too and add a deprecation warning. |
With the support of generic stores, it becomes acceptable for the default implementation (namespace-store) to contain what is now in plugins. This functionality will be limited to namespace-store plugins and will not be present when using `registerGenericStore`.
This moves the persistence feature out of a data plugin (which will be deprecated) into the namespace-store default implementation of a wp.data generic store. It also moves the tests into appropriate places and adds new ones at the newly exposed functions.
With the two internal data plugins now built into namespace-store, registry.use can be deprecated in preference of using `registerGenericStore` for implementing custom behavior
@youknowriad I have moved the persistence plugin into |
The e2e test error looks like it has been happening randomly on unrelated builds as well, so I think it's a false failure. Can someone please retrigger the build? Thanks. |
deprecated( 'registry.use', { | ||
alternative: 'registry.registerGenericStore', | ||
plugin: 'Gutenberg', | ||
version: '4.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.
We should remove the version here, we can't remove APIs anymore. We need to figure out the deprecation strategy first.
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.
I'm not sure what the next steps are for this now that it can't be removed. So whatever you want to do is fine.
' wp.data', | ||
' .use( wp.data.plugins.persistence, { storageKey: storageKey } )', | ||
' .use( wp.data.plugins.controls );', | ||
' wp.data.setPersistenceDefaults( { storageKey: storageKey } );', |
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.
Not sure about the naming of this function.
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.
I'm not a huge fan of this approach either, honestly. It's due to an artifact of the global registry. Feel free to rename or modify as you prefer.
Hmm, I must have missed this part of the discussion in #10289 . It's not immediately obvious why we'd care to bake in all possible behaviors to the namespace store. I understand |
I agree that you should opt-in into persistence and controls, it is still possible right now because these are options you pass to the store. But I think I find it confusing to allow |
I'm not sure how to express it but even if I liked the |
@aduth and @youknowriad - do we still want to deprecate plugin support given that it was included in WordPress 5.0 release? By the way, this plugin got stale and would have to be refreshed with the latest changes from |
I vehemently disagreed with this one from the beginning 😄 |
I still think there's an inconsistency in our current code base. This API is only useful for "namespace stores" but it's defined by default in the registry object for all stores while it doesn't apply for any other implementation. I still think this is a duplicate of the My thinking is that we can remove it at the moment but at least we should clarify that it's not the way we should add behavior to stores. |
@youknowriad As I look to implement what I'd described in #13088 (comment) , my intuition led me to think that "plugins" were the best pattern we had to align with an implementation for history. I'm not sure I follow the exact concerns you laid out in your previous comment, where to me, the namespace-stores were what we assumed to be the default / preferred implementation, and "generic" exposed as a niche side-case. Your prior comment makes it sound as though we optimize for the latter, though. And in which case, what alternative option would you consider for adding behaviors to stores, and particularly for those which might operate across stores (like history would). The editor middlewares approach is what I see as our other alternative here, but this is in its own way a very inelegant approach, at least if it were to be implemented from scratch for each store. |
Reducer-enhancers / higher-order reducers is another pattern we have, particularly relevant to this discussion since it's how we implement history today. The ideas in #13088 (comment) still pose a unique challenge in how we manage history across stores, though it seems like something where a global shared state could be appropriate (or at least per-session "global", as in a top-level registry, considering server-side implications if it's something to support). |
Related previous note about the idea for a module of reducer-enhancers: #9617 (comment)
|
I don't see it this way, for me the namespace store is just another implementation of a store (it could be an extension itself as Right now, when you do @aduth I think we need to distinguish two things here: 1- The idea that when you use the namespace store, you can opt-in to features like persistence, history, controls... I'm totally ok with this idea, I think it's good. What I'm not confident with is the way we add those features today. 2- The Also, I think after using this API, I'm not a fan of it because it's not clear what you can and can't do with it, you need to read the namespace store implementation to know how you can extend it. The way you write these plugins is very tied to the original implementation of the namespace store. |
I discussed this PR with @coderkevin in private chat. I think we should close this issue for now as he is not going to work on it until we have a clear path how to proceed further. As soon as there is an agreement on the final shape of this proposal, he is happy to reopen this PR and help to land it. |
Fixes #11449
Description
With the support of generic stores, it becomes acceptable for the
default implementation (namespace-store) to contain what is now in
plugins. This functionality will be limited to namespace-store plugins
and will not be present when using
registerGenericStore
.This PR builds the existing
controls
andpersistence
plugins into thenamespace-store
default implementation of stores for@wordpress/data
. It also deprecates the anduse
function from the registry as they it will no longer be needed.How has this been tested?
All existing tests pass.
Tested editor in Chrome and Firefox browsers (although browser support should not affect this PR).
Types of changes
This removes the use of plugins from internal
@wordpress/data
code and deprecates theuse
function.Checklist: