[wp-trac] [WordPress Trac] #50568: Improve WP_Term's sanitization calls
WordPress Trac
noreply at wordpress.org
Mon Jul 6 07:04:45 UTC 2020
#50568: Improve WP_Term's sanitization calls
--------------------------+-----------------------------
Reporter: Cybr | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: trunk
Severity: normal | Keywords: has-patch
Focuses: performance |
--------------------------+-----------------------------
Akin to `WP_Post::filter()`, I think `WP_Term::filter()` should have a
bypass, too. This will significantly improve performance wherever terms
are used (list edit screens, category widgets, blocks) because the bypass
prevents redundant re-sanitization.
The attached patch will shave off a 30% load time at `wp-admin/edit.php`
after #50567's implementation. This patch tests for the `WP_Term` object's
`::$filter` state, and only re-sanitizes the term when the state differs
from the input argument.
You'll also find that `sanitize_term()` now looks a lot like
`sanitize_post()`--the same goes for `get_term()`'s resemblance to
`get_post()`. Overall, it seems posts have received a lot more love over
the years, and this patch steals some of that.
There are a few issues with terms, however. For example,
`update_term_cache()` caches terms regardless of being shared, while
`WP_Term::get_instance()` tries to prevent that. The `$filter = 'display'`
argument is used in contexts where `raw` would do fine, too (e.g. @
`WP_Terms_List_Table::single_row()`). If we iron those issues out, we can
fully phase out the re-sanitization of terms.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50568>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list