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

Gutenberg 18.6.1 causes fatal error with WordPress 6.4.5 #62986

Closed
beckej13820 opened this issue Jun 28, 2024 · 6 comments · Fixed by #63082
Closed

Gutenberg 18.6.1 causes fatal error with WordPress 6.4.5 #62986

beckej13820 opened this issue Jun 28, 2024 · 6 comments · Fixed by #63082
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] HTML API An API for updating HTML attributes in markup [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@beckej13820
Copy link

beckej13820 commented Jun 28, 2024

Description

This is a problem that first appeared on a Multisite with ~500 sites, but was then replicated on a fresh WordPress multisite with no other plugins enabled.

Gutenberg plugin is causing a fatal error when activated on a WordPress running 6.4.5

Fatal error: Uncaught Error: Call to undefined method WP_HTML_Tag_Processor::next_token() in /home/edbecksu/demo.ed-beck.com/gutenberg/wp-content/plugins/gutenberg/build/block-library/blocks/button.php:44 Stack trace: #0 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(258): gutenberg_render_block_core_button(Array, '\n\t\t\t<div class=...', Object(WP_Block)) 
#1 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(244): WP_Block->render() 
#2 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(244): WP_Block->render() 
#3 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(244): WP_Block->render() 
#4 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1512): WP_Block->render() 
#5 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1550): render_block(Array) 
#6 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-content/plugins/gutenberg/build/block-library/blocks/pattern.php(70): do_blocks('\n<!-- wp:group ...') 
#7 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(258): gutenberg_render_block_core_pattern(Array, '', Object(WP_Block)) 
#8 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1512): WP_Block->render() 
#9 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1550): render_block(Array) 
#10 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-content/plugins/gutenberg/build/block-library/blocks/pattern.php(70): do_blocks('\n<!-- wp:patter...') 
#11 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(258): gutenberg_render_block_core_pattern(Array, '', Object(WP_Block)) 
#12 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(244): WP_Block->render() 
#13 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1512): WP_Block->render() 
#14 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1550): render_block(Array) 
#15 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-content/plugins/gutenberg/build/block-library/blocks/pattern.php(70): do_blocks('\n<!-- wp:templa...') 
#16 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/class-wp-block.php(258): gutenberg_render_block_core_pattern(Array, '', Object(WP_Block)) 
#17 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1512): WP_Block->render() 
#18 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/blocks.php(1550): render_block(Array) 
#19 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/block-template.php(263): do_blocks('<!-- wp:pattern...') 
#20 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/template-canvas.php(12): get_the_block_template_html() 
#21 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-includes/template-loader.php(106): include('/home/edbecksu/...') 
#22 /home/edbecksu/demo.ed-beck.com/gutenberg/wp-blog-header.php(19): require_once('/home/edbecksu/...') 
#23 /home/edbecksu/demo.ed-beck.com/gutenberg/index.php(17): require('/home/edbecksu/...') 
#24 {main} thrown in /home/edbecksu/demo.ed-beck.com/gutenberg/wp-content/plugins/gutenberg/build/block-library/blocks/button.php on line 44

Step-by-step reproduction instructions

  1. Install a fresh WordPress Multisite running WordPress 6.4.5
  2. Install and activate the Gutenberg plugin
  3. The site will have a critical error / white screen

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress Version 6.4.5
  • Gutenberg Version 18.6.1
  • Theme Twenty Twenty Four

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@beckej13820 beckej13820 added the [Type] Bug An existing feature does not function as intended label Jun 28, 2024
@ndiego
Copy link
Member

ndiego commented Jun 28, 2024

I can confirm. To easily test, here's a Playground link.

@t-hamano
Copy link
Contributor

When WordPress 6.6 is released, the WordPress version supported by the Gutenberg plugin will be raised to 6.5, but for now I think the Gutenberg plugin may need to support WordPress 6.4.

Perhaps the changes made in #58107 are also needed for lib/compat/wordpress-6.4/html-api/.

cc @dmsnell

@t-hamano t-hamano added Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] HTML API An API for updating HTML attributes in markup labels Jun 29, 2024
@beckej13820 beckej13820 changed the title Gutenberg 18.6.1 causes fatal error with Wordpress 6.4.5 Multisite Gutenberg 18.6.1 causes fatal error with Wordpress 6.4.5 Jun 29, 2024
@dmsnell
Copy link
Member

dmsnell commented Jul 1, 2024

next_token() was introduced in WordPress 6.5 so this is why it's breaking, but I don't see where Gutenberg creates the render_core_block_button() function that is triggering the error. That change appears in WordPress/wordpress-develop#6773, but I don't see where it came from - "packages".

@t-hamano adding changes to the compat directory won't solve this because the button rendering code is directly referring to the WP_ class. We'd have to find the place where it does that and reference a Gutenberg_ compat class with the updates.

If we can find the source of this code that will help fix it. Otherwise, in two weeks Gutenberg won't support 6.4 anymore so if it takes longer than that to fix, it's possibly worth waiting.

I may have reviewed the PR that made the change but I can't find it now.

@t-hamano
Copy link
Contributor

t-hamano commented Jul 2, 2024

Thank you for your feedback.

It may be easiest to wait until the Gutenberg plugin drops support for 6.4, but I'm concerned that the issue will remain for sites using a Gutenberg plugin version that supports 6.4.

I think the ideal solution would be the following, what do you think?

  1. Refactor the Button block without using the next_token() method (next_token() was added in this PR)
  2. Gutenberg drops support for 6.4
  3. Refactor the Button block to use next_token() again

@dmsnell
Copy link
Member

dmsnell commented Jul 2, 2024

@t-hamano perhaps the easiest option would be to copy the updates to the HTML API into Gutenberg with a Gutenberg_ prefix and then use that in the button block, instead of WP_ where it calls next_token().

I noticed that there's already a Gutenberg_HTML_Tag_Processor_6_5 in there, which I think should be available for use in the button block. I always get confused though with the compat layer, if a 6.4 deployment loads the 6.5 compatibility layers. @ockham has helped me out endlessly before on these matters.

If that doesn't work we should only need to bring the Core version of the Tag Processor for 6.4/6.5 into Gutenberg and create a Gutenberg_ prefix (ensuring all dependent classes are available), and then calling that from the button instead of the WP_ version.

@annezazu annezazu changed the title Gutenberg 18.6.1 causes fatal error with Wordpress 6.4.5 Gutenberg 18.6.1 causes fatal error with WordPress 6.4.5 Jul 2, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 3, 2024
@talldan
Copy link
Contributor

talldan commented Jul 4, 2024

@beckej13820 Thanks for reporting this, version 18.7.1 of the Gutenberg plugin has just rolled out and will have @t-hamano's fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] HTML API An API for updating HTML attributes in markup [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants