Elements tests: Accept both md5 and sequential wp-elements-* class names#79300
Merged
Conversation
…in tests
WordPress core changed `wp_get_elements_class_name()` from an md5 hash of the
serialized block (`wp-elements-{md5}`) to a sequential id via
`wp_unique_prefixed_id()` (`wp-elements-1`, `wp-elements-2`, …), to avoid class
name collisions between identical blocks.
The element support test asserted the md5 form, so it fails against the newer
core. Gutenberg runs against the current and previous WordPress versions — md5
on older cores, sequential on newer — so the patterns now accept either form to
stay green across all supported versions.
No production change is needed: `lib/block-supports/elements.php` calls
`wp_get_elements_class_name()` with an argument the newer (no-arg) function
ignores, while older cores still require it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Contributor
Author
|
Thanks for the quick review! As this was blocking open PRs, I've force merged after the PHP actions completed but before the e2es and perf tests completed (since this PR doesn't change the runtime behaviour of the plugin at all). |
Contributor
|
Thank you for noticing! |
adamsilverstein
pushed a commit
that referenced
this pull request
Jun 24, 2026
…in tests (#79300) WordPress core changed `wp_get_elements_class_name()` from an md5 hash of the serialized block (`wp-elements-{md5}`) to a sequential id via `wp_unique_prefixed_id()` (`wp-elements-1`, `wp-elements-2`, …), to avoid class name collisions between identical blocks. The element support test asserted the md5 form, so it fails against the newer core. Gutenberg runs against the current and previous WordPress versions — md5 on older cores, sequential on newer — so the patterns now accept either form to stay green across all supported versions. No production change is needed: `lib/block-supports/elements.php` calls `wp_get_elements_class_name()` with an argument the newer (no-arg) function ignores, while older cores still require it. Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fix failing Elements PHP tests
Why?
In WordPress/wordpress-develop@fc826ae#diff-ba4dd61bebec568429765848157ef087c9a4008d7d8297ba1e107214f44ec91d and WordPress/wordpress-develop#12126 the construction of the elements class name changed from an md5 to a sequential number.
So, we need to update the tests accordingly, while factoring in that our tests might run against different WP versions (because GB supports earlier WP versions than latest trunk). I might have gotten that nuance wrong, so happy to close this PR if there's a better approach!
How?
Update the regexes used in the elements tests to match against both the md5 approach and the sequential numbering approach.
Note: this drifts from the changes made in WordPress/wordpress-develop#12126 as in Gutenberg we need to account for different WP versions, I believe? Either way, I think we can land this to unblock GB trunk, and can follow-up separately if need be.
Testing Instructions
See if the tests pass now
Use of AI Tools
Claude Code