[wp-trac] [WordPress Trac] #55996: the get_the_block_template_html call all the same functions as the the_conent filter so they are run twice
WordPress Trac
noreply at wordpress.org
Mon Sep 11 21:45:44 UTC 2023
#55996: the get_the_block_template_html call all the same functions as the
the_conent filter so they are run twice
-------------------------------------------------+-------------------------
Reporter: pbearne | Owner: flixos90
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.4
Component: Formatting | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests changes- | Focuses:
requested | performance
-------------------------------------------------+-------------------------
Comment (by flixos90):
Revisiting this ticket, I would like us to take a step back and rethink
what we want to accomplish here.
While this ticket is explicitly focused on avoiding duplicate execution of
certain functions on the same content, I am unsure whether that is what we
really want, because:
* There are valid reasons to re-process certain content even if it was
already processed at another processing layer: For example, a plugin or
even core itself could implement image loading optimization logic at the
entire block template level (`template` context) to refine the attributes
that core otherwise would add at the post content level (`the_content`
context). Such a thing would not be possible if we were preventing already
processed content to be re-processed.
* While it seems undesirable from a performance perspective to process
certain content multiple times, I don't think it would make a notable
difference for performance since the processing logic would still need to
be initialized just as before: For example, to parse blocks at the entire
block template level, we still need to initialize all the block parsing
logic even if the post content blocks were already parsed. And there
wouldn't be any duplication either because already parsed blocks wouldn't
be reparsed.
While based on that I lean towards changing course on this ticket, that is
not to say we just leave it as is. There are certainly some problems that
result from the double execution that we can solve. Here's a few that were
brought up before that could be addressed separately:
* Certain functions like `wptexturize()` or `convert_smilies()` may not be
desirable for some sites to run, and right now there is no way to remove
them from the block template level, even when they're being removed from
`the_content` filter. What we could do here is replace the hard-coded
function list in `get_the_block_template_html()` with a regular filter and
callbacks just like in the other cases so that functions can be
added/removed. [https://github.com/WordPress/wordpress-develop/pull/5188
See draft pull request]
* Certain extension points for plugins/themes, such as the
`wp_content_img_tag` filter, are applied in different contexts and thus
may process the same content twice which from an API perspective would be
unexpected and can lead to problems such as an attribute being added
twice. What we could do here is to use context specific filters so that
developers wouldn't by accident make certain modifications twice.
[https://github.com/WordPress/wordpress-develop/pull/5189 See draft pull
request]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55996#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list