-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Tag Processor: Only define classes if they don't already exist. #47434
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
Conversation
adamziel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you!
Oh, and the linter is ruthless and wants us to indent these classes :-(
|
The linter is ruthless, I agree 😄 I wasn't sure what ignore-statement I needed to find to blast over the code to get the linter to chill out. None of the classes in Core are indented, and I couldn't find any ignore comments there so I think the linter only marches over Gutenberg. If I can find the ignore comment I'll add it. |
1a3c5eb to
400a4da
Compare
|
The linter problem seemed more challenging than I first expected: because the problem isn't the In response I have taken an approach that is objectively less safe so I don't have to fight against the linter. |
|
Flaky tests detected in 400a4da. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4021526132
|
400a4da to
b25d218
Compare
In preparation for a merge into WordPress 6.2 we're wrapping the class definitions for the HTML Tag Processor and its dependent helper classes in checks for whether they already exist. Additionaly we've renamed the `index.php` file to `wp-html.php` to better align with its role of loading the WordPress HTML parsing subsystem, both with the Tag Processor itself but also with future higher-level APIs and expansions on top of it. Co-Authored-By: Bernie Reiter <[email protected]>
b25d218 to
cf2b7b5
Compare
What?
Wraps HTML Tag Processor class definitions inside
if ( ! class_exists( … ) )checks.Why?
In preparation for a merge into WordPress 6.2 we're wrapping the class definitions for the HTML Tag Processor and its dependent helper classes in checks for whether they already exist. This ensures that they don't trigger errors if and when they are included both by Core and by the Gutenberg plugin on sites having the plugin installed.
How?
Using the
if ( … ) :andendif;syntax here to avoid introducing another indent level for what is essentially the entire file.If this file is required multiple times then successive calls will be effective noops.
Testing Instructions
If any problems are introduced here they should completely crash the PHP unit tests.