Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content may be removed on front-end during group inner container restoration on some PHP versions #30461

Closed
jeremyfelt opened this issue Apr 1, 2021 · 7 comments · Fixed by #30460
Labels
[Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended

Comments

@jeremyfelt
Copy link
Member

Description

The regex used in gutenberg_restore_group_inner_container() does not appear to work as intended on all PHP versions for some content. This can lead to content being removed from the front-end when Gutenberg 10.3.0 is activated.

An initial example of content that breaks with the regexes in that function: https://3v4l.org/Q9mVk

  • PHP 5.6, 7.3, 7.4, and 8 return 1 for the initial preg_match() and will then not process the content with the second regex.
  • PHP 7.0, 7.1, and 7.2 return false for the initial preg_match() and then assign NULL to $updated_content in the second regex.

The sample content is structured as:

  • Group
    • Group
      • Heading
      • Columns
        • Column
        • Column
    • Heading
    • Columns
      • Column
      • Column

I'm not confident if this is due to a group wrapping a group, or what, but it is content that was working on my home page with Gutenberg 10.2.0 and then stopped working on upgrade to 10.3.0. Deactivating the plugin brings the content immediately back. The content always appears fine in the editor.

Related #30443, #30453

Code snippet (optional)

Markup and regex example from gutenberg_restore_group_inner_container(): https://3v4l.org/Q9mVk

WordPress information

  • WordPress version: 5.7.0
  • Gutenberg version: 10.3.0
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes
@youknowriad youknowriad added [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention labels Apr 1, 2021
@youknowriad
Copy link
Contributor

Thanks for writing this issue. I'm trying to improve the regex here #30460 but still noticing some content loss with the example content provided in #30443

Feel free to chime-in and improve the regex. I'm no expert there.

@youknowriad
Copy link
Contributor

youknowriad commented Apr 1, 2021

So for me the regex in #30460 seems correct but there might be a memory problem for long posts like this one https://3v4l.org/gUpmT

@ockham
Copy link
Contributor

ockham commented Apr 1, 2021

Trying to swap the m modifier for an s, and replacing the obscure (\s|\S|.)* by just .*: https://3v4l.org/H20C4

@ockham
Copy link
Contributor

ockham commented Apr 1, 2021

ms (both modifiers together) also works, as long as we replace (\s|\S|.)* by .* (which the s modifier allows us to do).

Edit: Test: https://3v4l.org/bVPFM

@nbatteur
Copy link

nbatteur commented Apr 2, 2021

HI, as requested here is my configuration:

Server architecture Linux 3.10.0-693.11.6.el7.x86_64 x86_64
Web server Apache
PHP version 7.3.27 (Supports 64bit values)
PHP SAPI fpm-fcgi
PHP max input variables 2000
PHP time limit 300
PHP memory limit 2048M
Max input time 6000
Upload max filesize 64M
PHP post max size 64M
cURL version 7.29.0 NSS/3.53.1
Is SUHOSIN installed? No
Is the Imagick library available? Yes
Are pretty permalinks supported? Yes
.htaccess rules Custom rules have been added to your .htaccess file.

@ockham
Copy link
Contributor

ockham commented Apr 2, 2021

@nbatteur Thanks for sharing your config. We believed we've fixed the issue you were experiencing, and we released Gutenberg v10.3.1 to include the relevant fixes. Can you try if that version fixes the issue for you?

@nbatteur
Copy link

nbatteur commented Apr 2, 2021

Its good ! I just tested on our test machine and everything works again with this new version. Thank you very much for the work done!
And on prod server too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants