Skip to content

Use default version for hash generation if not set - #33

Merged
rmccue merged 4 commits into
masterfrom
hotfix-set-default-asset-version
Feb 24, 2026
Merged

rmccue merged 4 commits into
masterfrom
hotfix-set-default-asset-version

Conversation

@mattheu

@mattheu mattheu commented Feb 16, 2026 •

Copy link
Copy Markdown
Member

I've been running into a bug: for a block theme, the core block styles fail to load after updating WordPress as the integrity hash check fails. This is despite the version no appended to the src changing. Clearing CDN cache doesn't solve the problem.

This affects core block styles like:

/wp-includes/blocks/navigation/style.min.css
/wp-includes/blocks/cover/style.min.css
/wp-includes/blocks/social-links/style.min.css
/wp-includes/blocks/image/style.min.css

This is because - for core blocks, no version is provided at the point the styles are registered. The version in block metadata is not used and it is hardcoded to false. Note that assets without versions do default to the current WordPress version number however this is only done at the point the tag is output.

I think the best fix for this is, to use the the default version when calculating the cache key if no version is explicitly provided.

@rmccue

rmccue commented Feb 17, 2026

Copy link
Copy Markdown
Member

Good catch!

I think the implementation here needs to be slightly more complex. The logic in core is that if the value is null, it's equal to ''; if it's otherwise falsey (and the default parameter is false), then it defaults to the version of core (specifically get_bloginfo( 'version' )).

@mattheu

mattheu commented Feb 18, 2026 •

Copy link
Copy Markdown
Member Author

@rmccue Thanks for your feedback - yes good spot. Updated to ensure logic is exactly the same as core (Both WP_Scripts and WP_Styles do it lik this)

Comment thread inc/namespace.php Outdated
@rmccue
rmccue merged commit d032641 into master Feb 24, 2026
0 of 2 checks passed
@rmccue
rmccue deleted the hotfix-set-default-asset-version branch February 24, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants