[wp-trac] [WordPress Trac] #44467: Ensure meta wrapper functions do not contain additional logic
WordPress Trac
noreply at wordpress.org
Sun Jul 8 15:20:31 UTC 2018
#44467: Ensure meta wrapper functions do not contain additional logic
-------------------------------------------------+-------------------------
Reporter: flixos90 | Owner: flixos90
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 5.0
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: 2nd-opinion has-patch needs-unit- | Focuses: multisite,
tests | rest-api
-------------------------------------------------+-------------------------
Changes (by flixos90):
* keywords: 2nd-opinion => 2nd-opinion has-patch needs-unit-tests
* owner: (none) => flixos90
* status: new => assigned
* milestone: Awaiting Review => 5.0
Comment:
After talking to @johnjamesjacoby about this, we agreed to proceed with
this. Let's use this ticket here since it goes a little further than
#43813. It will likely fix that as well.
[attachment:"44467.diff"] is the implementation I envision for it. Some
notes:
* For posts, terms, comments, and sites updating the cache has been
removed from the wrapper functions and instead now happens through
separate actions hooked into the respective `added_{$meta_type}_meta`,
`updated_{$meta_type}_meta`, and `deleted_{$meta_type}_meta` hooks. Those
only fire on success, so they replicate the current behavior.
* For terms and sites, the checks for whether that type of metadata is
supported has been removed from the wrapper functions and instead now
happens through separate filters hooked into the respective
`get_{$meta_type}_metadata`, `add_{$meta_type}_metadata`,
`update_{$meta_type}_metadata`, and `delete_{$meta_type}_metadata` hooks.
* In order to catch all possible access to the metadata tables,
particularly for the point above, four new pre-filters were introduced:
`get_{$meta_type}_metadata_by_mid`, `update_{$meta_type}_metadata_by_mid`,
`delete_{$meta_type}_metadata_by_mid`, and
`update_{$meta_type}_metadata_cache`. Those should be merged in a separate
commit before the actual changes this ticket is for.
* With the additional filters, and the pre-filters and post-set-cache-
actions being hooked in everywhere, it is furthermore ensured that a few
more cases than before are properly covered.
* Rerouting the post ID if it is for a revision should remain in the post
meta wrappers. There is no hook to integrate this directly into the meta
functions, and more importantly it shouldn't be tied to it as it would
otherwise prevent plugins to easily implement metadata for post revisions.
* Checking for whether a term is shared should remain in the term meta
wrappers. It is really specific, and not as foundational that you would be
required to prevent access to the term meta database table because of it.
I will work on unit tests after an initial review once we agree on whether
this is the approach to proceed with.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44467#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list