Skip to content

Elements tests: Accept both md5 and sequential wp-elements-* class names#79300

Merged
andrewserong merged 1 commit into
trunkfrom
fix/elements-class-name-test-wp-trunk
Jun 18, 2026
Merged

Elements tests: Accept both md5 and sequential wp-elements-* class names#79300
andrewserong merged 1 commit into
trunkfrom
fix/elements-class-name-test-wp-trunk

Conversation

@andrewserong

@andrewserong andrewserong commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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

…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>
@andrewserong andrewserong self-assigned this Jun 18, 2026
@andrewserong andrewserong added the [Type] Bug An existing feature does not function as intended label Jun 18, 2026
@andrewserong andrewserong added the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Jun 18, 2026

@talldan talldan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LTGM

@github-actions

Copy link
Copy Markdown

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: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>

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

@andrewserong andrewserong enabled auto-merge (squash) June 18, 2026 03:05
@andrewserong andrewserong disabled auto-merge June 18, 2026 03:07
@andrewserong andrewserong merged commit 917b119 into trunk Jun 18, 2026
52 of 55 checks passed
@andrewserong andrewserong deleted the fix/elements-class-name-test-wp-trunk branch June 18, 2026 03:07
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 18, 2026
@andrewserong

Copy link
Copy Markdown
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).

@t-hamano

Copy link
Copy Markdown
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants