[wp-trac] [WordPress Trac] #54013: wp_restore_group_inner_container() causes duplicate inner container on content that already has an inner container
WordPress Trac
noreply at wordpress.org
Thu Aug 26 10:41:28 UTC 2021
#54013: wp_restore_group_inner_container() causes duplicate inner container on
content that already has an inner container
--------------------------+-----------------------------
Reporter: davecpage | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.8
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I have a site that was originally authored in WP 5.7, when the group block
added into the content an inner container div. The theme CSS relies upon
this container to set an overall width from the parent.
When the site was upgraded to 5.8 we noticed that there were width issues
on groups, and the reason why was due to a duplicate inner container. When
attempting to edit the page in the editor the content was "fixed". We
realised it was because the group block now removes the inner container
from the HTML, with the function `wp_restore_group_inner_container()`
restoring it if required.
The problem appears to be that the function will often "restore" the inner
container even if it's already there. I eventually tracked it down to the
initial regex used to detect if it's there. The regex appears to be more
complex than required. The capturing of groups is unused for example. At
the most simplest level, just changing the regex so that quantifiers are
ungreedy causes it to no longer fail in a double adding way.
It was difficult to test on my local environment, but more consistant on
our staging. I think because of the number of steps that the regex goes
through. I can imagine different hosts having different limits for
performance.
Simple PHP showing the modified regex on the same content
https://3v4l.org/1s7cT
Originally added as https://github.com/WordPress/gutenberg/issues/34199
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54013>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list