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

Button Block: Add back compat for WP6.4 regarding HTML Tag Processor #63082

Merged
merged 5 commits into from
Jul 4, 2024

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Jul 3, 2024

Fixes #62986

What?

This PR fixes a fatal error in the Button block, caused by the WP_HTML_Tag_Processor class in WP6.4 not yet having the next_token() method.

Fatal error: Uncaught Error: Call to undefined method WP_HTML_Tag_Processor::next_token() in /var/www/html/wp-content/plugins/gutenberg/build/block-library/blocks/button.php:44

How?

A class with the next_token method exists in the Gutenberg plugin as Gutenberg_HTML_Tag_Processor_6_5. I set it up so that this class is used if the IS_GUTENBERG_PLUGIN variable is true. This prevents a critical error that occurs when the Gutenberg plugin is used in WP6.4.

In my opinion, the following flow would allow us to maintain full backward compatibility:

  1. July 3rd (today): Gutenberg 18.7 was released.
  2. Merge this PR.
  3. July 16th: WordPress 6.6 will be officially released.
  4. July 17th: Gutenberg 18.8 will be shipped with this PR included, which will fix the issue with WP6.4.
  5. The Gutenberg plugin will drop support for WP6.4.
  6. (TODO) Remove the fallback approach made in this PR.

Testing Instructions

  • Deactivate the Gutenberg plugin and downgrade to WP 6.4.
  • Insert a Button block into a post and publish it.
  • Activate the Gutenberg plugin and visit the post.
    • trunk: You will get a critical error.
    • This PR: You should not get a critical error and the Button block should render.

@t-hamano t-hamano added Backwards Compatibility Issues or PRs that impact backwards compatability [Block] Buttons Affects the Buttons Block labels Jul 3, 2024
@t-hamano t-hamano self-assigned this Jul 3, 2024
@t-hamano t-hamano added the [Type] Bug An existing feature does not function as intended label Jul 3, 2024
@t-hamano t-hamano marked this pull request as ready for review July 3, 2024 11:01
@t-hamano t-hamano requested a review from ajitbohra as a code owner July 3, 2024 11:01
Copy link

github-actions bot commented Jul 3, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: beckej13820 <beckej@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

github-actions bot commented Jul 3, 2024

Flaky tests detected in 7835c9f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9778816524
📝 Reported issues:

Copy link
Contributor

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@t-hamano I'd be grateful if you could address my comment below. Thank you.

packages/block-library/src/button/index.php Outdated Show resolved Hide resolved
packages/block-library/src/button/index.php Outdated Show resolved Hide resolved
@talldan
Copy link
Contributor

talldan commented Jul 4, 2024

Thanks for addressing this. I realize it was my mistake that's lead to this situation.

July 16th: WordPress 6.6 will be officially released.
July 17th: Gutenberg 18.8 will be shipped with this PR included, which will fix the issue with WP6.4.

Given 18.8 is released after WordPress 6.6, I think support for WordPress 6.4 can be dropped in 18.8.

Perhaps this PR can be shipped in a Gutenberg 18.7.1 release (I'm happy to handle the release process).

t-hamano and others added 2 commits July 4, 2024 13:20
Re-add conditional statement

Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>
@t-hamano
Copy link
Contributor Author

t-hamano commented Jul 4, 2024

Thank you everyone for your feedback. I think I've made the appropriate changes to the code, but I'd appreciate it if you could also check that this comment is clear.

Perhaps this PR can be shipped in a Gutenberg 18.7.1 release (I'm happy to handle the release process).

That is very much appreciated 🙇‍♂️

@talldan
Copy link
Contributor

talldan commented Jul 4, 2024

I'd appreciate it if you could also check that this comment is clear.

Yep, I think it's very clear 👍

@t-hamano t-hamano merged commit 0d13e80 into trunk Jul 4, 2024
60 checks passed
@t-hamano t-hamano deleted the button/compat-for-wp64 branch July 4, 2024 05:23
@github-actions github-actions bot added this to the Gutenberg 18.8 milestone Jul 4, 2024
@talldan talldan added the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Jul 4, 2024
@talldan talldan modified the milestones: Gutenberg 18.8, Gutenberg 18.7 Jul 4, 2024
talldan added a commit that referenced this pull request Jul 4, 2024
…63082)

* Button Block: Add back compat for WP6.4 regarding HTML tag processor

* Don't use conditional statement

* Update packages/block-library/src/button/index.php

Re-add conditional statement

Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>

* Fix lint and update comment

* Remove space

---------

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: beckej13820 <beckej@git.wordpress.org>
@talldan
Copy link
Contributor

talldan commented Jul 4, 2024

I've cherry picked this to the 18.7 release branch - b6310be

@talldan talldan removed the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Jul 4, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jul 18, 2024
…ordPress#63082)

* Button Block: Add back compat for WP6.4 regarding HTML tag processor

* Don't use conditional statement

* Update packages/block-library/src/button/index.php

Re-add conditional statement

Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>

* Fix lint and update comment

* Remove space

---------

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: beckej13820 <beckej@git.wordpress.org>
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 [Block] Buttons Affects the Buttons Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gutenberg 18.6.1 causes fatal error with WordPress 6.4.5
5 participants