Opened 3 years ago
Closed 2 years ago
#54013 closed defect (bug) (reported-upstream)
wp_restore_group_inner_container() causes duplicate inner container on content that already has an inner container
Reported by: | davecpage | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.8 |
Component: | General | Keywords: | has-patch has-screenshots close |
Focuses: | Cc: |
Description
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
Attachments (5)
Change History (7)
#1
@
3 years ago
- Keywords has-patch has-screenshots close added
Hi, not sure how this needs to close as the change has been implemented upstream as part of Gutenberg, see https://github.com/WordPress/gutenberg/issues/34199, which in itself has been backported into WordPress for 5.9
Editor source of content in 5.7 showing singular inner container