[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
Sun Oct 16 17:59:55 UTC 2022


#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:  (none)
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  Awaiting Review
Component:  Formatting                    |     Version:
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  performance
------------------------------------------+------------------------------

Comment (by needle):

 Replying to [comment:10 manfcarlo]:
 > The problem you describe is not mentioned in the ticket description at
 all. The ticket description only identifies the problem of the filters
 being run twice on the same content, which, to my knowledge, the patch
 solves.

 The ticket doesn't actually mention a problem at all; it simply notes that
 there is duplication. I'm filling in the gaps, which are twofold:

 1. Some functions (e.g. `wptexturize`) that are usually applied via
 `the_content` filter are applied twice to the content.
 2. In non-block themes, it is possible to bypass these functions when they
 are applied via `the_content` filter. In block themes, as things stand,
 this is not possible.

 Your patch removes the core callbacks from `the_content` filter, which
 addresses (1) but does not address (2).

 > In other words, with the patch, none of the filters identified in the
 ticket description should ever run more than once on the same content.
 Unwanted effects such as #54614 and #56295 are believed to be directly
 caused by the double filters, so the patch should solve them.

 I agree with you on this but disagree with your choice of which calls to
 remove. In my opinion, it is the direct calls in
 `get_the_block_template_html()` that should be removed (because they break
 the existing functionality that some plugins rely on) rather than removing
 the ''expected'' callbacks in `render_block_core_post_content()`. The
 result would be the same in terms of solving (1), but would also offer a
 path to solving (2).

 My knowledge of the knock-on effects of removing those function calls from
 `get_the_block_template_html()` is limited, but if they really do need to
 be called there, then I favour
 [https://github.com/WordPress/gutenberg/pull/17626#discussion_r329168610
 Weston Ruter's original suggestion] that they should be called via a
 separate hook rather than directly. They could then be unhooked or
 overridden if need be, which is not the case at present.

 > The argument here is rather fallacious and reminds me of people
 complaining that free speech is threatened because someone spoke out to
 disagree with them.

 Please don't be offensive. This is a technical discussion not a political
 one.

 > The only way to stop blocks like Custom HTML from being filtered by a
 core wrapper block is to delegate the filters to micro-level blocks such
 as Paragraph, which I would imagine is inefficient and not how the filters
 were originally intended to be used.

 Yes, this is indeed a condundrum. The reason why I used the example of the
 HTML block is that it neatly illustrates this conundrum.

 > I would not expect the core committers to agree to anything that breaks
 the pre-existing behaviour.

 I can't anticipate what core committers will do, but what I do know is
 that the direct function calls in `get_the_block_template_html()` are
 already breaking the pre-existing behaviour, so the question is how best
 to address that breakage.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55996#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list