-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
HTML Tag Processor: Add WP 6.3 compat layer #47933
Conversation
Flaky tests detected in 1d39251d152cb55855b9f4543397cf572b221adb. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4226314867
|
@ockham Couldn't we use the same Gutenberg class for 6.2 and 6.3 compat? |
It depends 😬 We could in theory remove the The textbook example where I'd definitely opt to keep both classes would be if the 6.3 one could actually inherit from the 6.2 one, but since we're modifying a There's another aspect: By having callers use the
However, this might also be a bit academic, since we'll have to retain the I don't have any strong preference either way. Curious to hear y'all's thoughts 😊 |
@ockham here's what Gutenberg needs to work with different WP versions:
How about we only ship if(!class_exist('WP_HTML_Tag_Processor')) {
class WP_HTML_Tag_Processor extends Gutenberg_HTML_Tag_Processor {}
} Advantages:
Disadvantages:
|
I'm a bit apprehensive about deriving It makes more sense to me to have |
That's exactly why I propose to derive the WP class from the GB class. A change in the behavior of a released public API is a BC break – I'd rather detect it surprises before 6.3 core merge. |
Not sure I see how that would work 🤔 For reference, I'll try to describe "my" scenario (
When preparing for the 6.3 Core merge, we should discover that Can you describe "your" scenario? 😊 |
@ockham here's my scenario:
When preparing for the 6.3 Core merge, we should discover that Gutenberg_HTML_Tag_Processor is used in a few places, and backport the features we have added to it to Core's WP_HTML_Tag_Processor (with @SInCE PHPDocs etc.) It's similar |
Alternative idea: what about moving all of the further development of the HTML API into core directly? I was going to start by suggesting we not allow any Gutenberg code to use the new version until it's in Core, but then if we do things there I think we can avoid all of this work. Right now the Tag Processor resolves its motivating need; future evolution is less about fixing a decades-old problem and more about opening up new possibilities nobody has used yet. The unit tests are in Core, the code is in Core, maybe we let this be and shift over there? |
Thank you @adamziel for elaborating your scenario! I've thought a bit more about it, and I think I'd be really uncomfortable to have Gutenberg declare a
@dmsnell If it was just about developing the HTML (Tag) Processor in isolation, I'd agree 100% and would keep development inside of |
If the above reasoning more or less 😬 works for y'all @adamziel @dmsnell -- would you be okay if we merged this PR? It's becoming a bit of a blocker to the more interesting stuff (see). (I'm happy to tweak it later if we see fit -- I don't think it's locking us into this particular approach too badly.) |
@dmsnell I like developing in Gutenberg because of the testing and feedback we get along the way – Gutenberg is installed on hundreds of thousands of sites. You may recall this has already helped solve a few critical bugs that we might have otherwise not found in time.
@ockham I agree some confusion would likely follow, but I think it would be worth it. Nevertheless, I don't insist. Let's move forward with this PR. |
* | ||
* @since 6.2.0 | ||
*/ | ||
class Gutenberg_HTML_Tag_Processor_6_3 extends WP_HTML_Tag_Processor { |
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.
Why Gutenberg_HTML_Tag_Processor_6_3
and not just Gutenberg_HTML_Tag_Processor
? Including 6_3 in the name means all the consumers of this API must specifically opt-in to this version – I don't think that's useful. For once, we wouldn't notice any E2E failures breaking the existing consumers.
based on the merge process we went through and the persistent complaints I hear from folks working on split-codebases I feel quite reluctant to merge this, having the impression we're setting ourselves up for more frustration later on. cc: @azaozz
developing within WordPress/WordPress-develop doesn't need to prevent us from using it in Gutenberg before a Core merge and release. maybe if we have something in development over there we can keep a copy here in Gutenberg and leave it hidden behind a I think something like that could resolve all of our needs, and as we've established, there's no reason we can't create our own vessel to work in while developing if the Core copy lags. as long as we're all coordinating and communicating and not rushing ahead of ourselves then we can still get what I think we're looking for by doing this work here. I've become fond of in other words:
in fact as I think about it it seems much easier to do this in Core and pull directly into GB via |
Quick reply (going to read/think/reply more in-depth tomorrow): I'm fine with trying your suggestion @dmsnell. However... ...on a practical level, I see one obstacle: Core is now in Beta stage, so essentially, only bugfixes are allowed to be merged into For the next three weeks, this could get somewhat in the way of what we hope to be an easier development flow 😕 |
yeah @ockham this is the part where a long-running branch comes into play. we can embrace I don't know that this will solve the problem, but it does seem to eliminate the need to have all of the funny naming and hasty changes during Core merge. |
I'll pull in a comment by @dmsnell from #47559 (comment), since it seems relevant to this PR:
TBH there's one part that I don't like about that strategy, and that's the fact that we'd only carry over updates from the long-running branch in My priority has always been to implement the remaining directives in the Block Interactivity API, and to that end, to make the missing features of the HTML (Tag) Processor available to it as swiftly as possible (see). This has worked nicely as long as they were developed inside of Gutenberg, as we could simply require the latest Gutenberg version as a prerequisite. The strategy you're proposing is kind of the diametrical opposite: Changes to the HTML (Tag) Processor would reach Gutenberg last rather than first 😅 Since Core will be in Beta Freeze until March 7, that would be the earliest date we'd be able to land the long-running branch, and it would make its way into Gutenberg no sooner than the first GB release after that. So I'd rather avoid that TBH, as I worry it would add friction to implementing the directives, which are kind of a high priority to the team. FWIW, I think we can avoid at least some of the issues of the Core merge process that we've seen during the 6.2 cycle. This time around, we can make sure we merge our code early during the upcoming 6.3 cycle into We'll still need a compat layer in GB, and it should probably carry a funny name 😉 in order to tell it apart from Core's The one thing I'll be sorely missing in GB is Are there any other things we'd get from developing inside |
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.
Would have merged this @ockham but I wanted to give you the chance to review my changes.
Are you running an autoformatter? It seems like your patch undid style changes pushed in Core on the module.
I removed the extends
because I don't know what it offers and because it introduces a real difference between this code and what's in Core. If this class remains a blind dump of updates in Core then I think we can just leave it identical except for adding the suffix, and I think that will ease updates since we won't have to start tracking a series of differences between Core's copy and Gutenberg's
git diff lib/compat/wordpress-6.3/html-api/class-wp-html-tag-processor-6.3.php ../wordpress-develop/src/wp-includes/html-api/class-wp-html-tag-processor.php
Not a blocker. If you have discussed it already then feel free to ignore it, but it makes it possible now to simplify the polyfill for WP_HTML_Tag_Processor for older versions of WordPress to: class WP_HTML_Tag_Processor extends Gutenberg_HTML_Tag_Processor_6_3 {} This way you could release changes in the Gutenberg plugin without refactoring usage to |
Currently this is a bit more complex :)
This case (older Gutenberg in newer WP) should actually be "doing it wrong" but don't think it is prevented for now. Just tried installing Gutenberg 11.8.3 in WP 6.2-beta2 and the plugin activated without problems. (I actually started a PR for fixing this, will revisit soon). So imho Gutenberg should probably always use its own version. In WP <= 6.1 there's no expectation to have |
Frankly I think it doesn't make much difference which repo is "main" and which is "secondary" as long as the code is synced regularly. As |
f3b8f24
to
ed2bd47
Compare
I've rebased and re-run the Performance Tests a couple of times, and they're still failing with the same error:
I'll look into this locally -- maybe there is a reproducible problem that results from loading the compat layer from |
ed2bd47
to
f3ec6d7
Compare
Alright, looks like Performance Tests have been failing for all of the most recently merged PRs. I guess I'll do what everyone else seems to be doing 🙈 Edit: Hold on, I seem to have lost @dmsnell's commit (see). I've now added it back. I'll let CI finish; might merge it only tomorrow, as I'm near the end of my day. (Unless you wanna go ahead @dmsnell -- feel free to!) |
Looks like perf tests have been fixed in #48240 🎉 Going to rebase. |
1d39251
to
53fa006
Compare
What?
Part of #44410.
Copy
lib/compat/wordpress-6.2/html-api/class-wp-html-tag-processor.php
tolib/compat/wordpress-6.3/html-api/class-wp-html-tag-processor.php
, and rename the class toGutenberg_HTML_Tag_Processor_6_3
.Why?
So we can continue developing the Tag Processor while retaining an exact copy of
WP_HTML_Tag_Processor
(as was merged into Core) in the 6.2 compat layer.How?
By copying the file from the 6.2 compat layer, and renaming the class to
Gutenberg_HTML_Tag_Processor_6_3
(and having it extendWP_HTML_Tag_Processor
). This is consistent with established practices.Note that since we're deriving from
WP_HTML_Tag_Processor
, we wouldn't really need to copy the entire class definition from the 6.2 layer. However, with PRs such as #47559 (which is modifying aprivate
method), we kind of do after all 😬Testing Instructions
Currently, the best test is to
diff
lib/compat/wordpress-6.2/html-api/class-wp-html-tag-processor.php
andlib/compat/wordpress-6.3/html-api/class-wp-html-tag-processor.php
and to verify that only theclass WP_HTML_Tag_Processor
line was changed toclass Gutenberg_HTML_Tag_Processor_6_3 extends WP_HTML_Tag_Processor
.