Compat: Remove filter that unsets auto-draft titles.#17317
Conversation
| // on the server. | ||
| records = castArray( records ).map( ( record ) => | ||
| record.status === 'auto-draft' ? { ...record, title: '' } : record | ||
| ); |
There was a problem hiding this comment.
this bundles a post-specific behavior to a generic entity handler. Can't we instead apply the filter to the REST API endpoint only instead of a global PHP filter?
There was a problem hiding this comment.
That would still break plugins that use the REST API and rely on the current behavior.
this bundles a post-specific behavior to a generic entity handler.
Yeah, it's unfortunate, but it won't break non-posts, it will just return the records.
There was a problem hiding this comment.
I thought the breakage was related to the usage of a specific WordPress function (and not the bahavior itself).
Is there a clean way we can move this out of the entities or make it generic somehow?
There was a problem hiding this comment.
I thought the breakage was related to the usage of a specific WordPress function (and not the bahavior itself).
Both
Is there a clean way we can move this out of the entities or make it generic somehow?
Not really, unless there is a way of adding plugin specific filters that I am not aware of.
There was a problem hiding this comment.
Can we at least create an issue maybe to not forget to think about how we can make this generic. Maybe some functions on the entities config or something?
Also, there's something that feels wrong here. We don't want this behavior in a generic way server-side but we do want it in the client side (which can is a bit non-sense) (The entities abstraction is generic and not specific to the editor).
There was a problem hiding this comment.
That works for me. What bothers me is that we're harding this in the entities actions, while it's specific to the post entities only. Do you think there's any way to move this to the editor store instead?
There was a problem hiding this comment.
Yes, but I don't think we want that.
By having it here we enforce the correct behavior on all new client side code, and non-post entities are not affected.
There was a problem hiding this comment.
Can we add a check to these two changes and ensure the "kind" is "postType"?
Reverts #16814
Resolves #17241
Description
This PR removes a filter that unsets auto-draft titles that was creating plugin compatibility issues and replaces it with client side code.
How has this been tested?
The test suites were ran and verified to still pass.
Types of Changes
Bug Fix: Don't unset auto-draft titles, because some plugins rely on it.
Checklist: