Cover: Avoid passing null as the featured image size - #81444
Conversation
The parallax/repeated branch passed `null` to `get_the_post_thumbnail_url()` when the `sizeSlug` attribute is absent, explicitly defeating the function's own `'post-thumbnail'` default. `$size` is documented as `string|int[]`, so `null` was never a valid value. `null` propagates down to `image_constrain_size_for_editor()`, which since WordPress r63177 evaluates `$_wp_additional_image_sizes[ $size ]` through `isset()`. On PHP 8.5 a null array offset is deprecated, which surfaces the latent bug as a test error. Use `'full'` rather than `'post-thumbnail'` so the rendered output is unchanged: `image_get_intermediate_size()` bails out early on a falsy `$size`, so the current code always resolves to the full-size URL. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
aduth
left a comment
There was a problem hiding this comment.
Would be good to have some test coverage here if we could, but given that this is blocking everything in trunk it's better to get a fix in place.
Reconciling this with the claim in the PR description:
I guess this is true and validates the decision to use It could be further improved with tests around |
|
Thanks for the review! This PR appears to be valid, as the unit tests are passing on PHP 8.5. |
|
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. |
|
I investigated the AI's analysis results. Ideally, for consistency with the |
|
This PR needs to be backported because the same CI error is occurring on the |
* Cover: Avoid passing null as the featured image size The parallax/repeated branch passed `null` to `get_the_post_thumbnail_url()` when the `sizeSlug` attribute is absent, explicitly defeating the function's own `'post-thumbnail'` default. `$size` is documented as `string|int[]`, so `null` was never a valid value. `null` propagates down to `image_constrain_size_for_editor()`, which since WordPress r63177 evaluates `$_wp_additional_image_sizes[ $size ]` through `isset()`. On PHP 8.5 a null array offset is deprecated, which surfaces the latent bug as a test error. Use `'full'` rather than `'post-thumbnail'` so the rendered output is unchanged: `image_get_intermediate_size()` bails out early on a falsy `$size`, so the current code always resolves to the full-size URL. Co-Authored-By: Claude <noreply@anthropic.com> * Cover: Add CHANGELOG entry Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>
|
I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: cdc13e2 |
This updates the pinned commit hash of the Gutenberg repository from `ea285b45692aed6c4f95353671393402f97f0aa7` to `b9743a015526ac8fd79298fd4e96cf002cee333b`. A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@ea285b4...b9743a0 - Style states: fix state deselection when selecting the already selected block (WordPress/gutenberg#81277) - Global styles: render element styles set only inside a breakpoint (WordPress/gutenberg#81265) - Style states: Fix phantom pseudo element style output (WordPress/gutenberg#81291) - Docs: remove breakpoint-only element style example from global styles guide (WordPress/gutenberg#81308) - theme.json schema: responsive states belong to blocks (WordPress/gutenberg#81253) - theme.json schema: allow responsive states on block style variations (WordPress/gutenberg#81309) - Render viewport state element styles in the editor (WordPress/gutenberg#81307) (WordPress/gutenberg#81311) - Site Editor: Decode HTML entities in Identity fields (WordPress/gutenberg#81269) (WordPress/gutenberg#81320) - Editor: Keep the canvas height stable while resizing the canvas (WordPress/gutenberg#81374) - Playlist: Normalize Waveform Player configuration handling (WordPress/gutenberg#81375) - Playlist: Improve audio conversion and track selection (WordPress/gutenberg#80926) (WordPress/gutenberg#81385) - fix: order site identity changes predictably (WordPress/gutenberg#81283) - Cover: Avoid passing null as the featured image size (WordPress/gutenberg#81444) - components/Menu: Restore Modal focus return when menu items close (WordPress/gutenberg#81446) - Notes: Fix text wrapping for long usernames in collaboration sidebar (WordPress/gutenberg#81406) - Site Editor: Use inverted ThemeProvider seed for portaled UI (WordPress/gutenberg#81296) Props wildworks. See #65529. git-svn-id: https://develop.svn.wordpress.org/branches/7.1@63209 602fd350-edb4-49c9-b593-d223f7449a82
* Cover: Avoid passing null as the featured image size The parallax/repeated branch passed `null` to `get_the_post_thumbnail_url()` when the `sizeSlug` attribute is absent, explicitly defeating the function's own `'post-thumbnail'` default. `$size` is documented as `string|int[]`, so `null` was never a valid value. `null` propagates down to `image_constrain_size_for_editor()`, which since WordPress r63177 evaluates `$_wp_additional_image_sizes[ $size ]` through `isset()`. On PHP 8.5 a null array offset is deprecated, which surfaces the latent bug as a test error. Use `'full'` rather than `'post-thumbnail'` so the rendered output is unchanged: `image_get_intermediate_size()` bails out early on a falsy `$size`, so the current code always resolves to the full-size URL. Co-Authored-By: Claude <noreply@anthropic.com> * Cover: Add CHANGELOG entry Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: aduth <aduth@git.wordpress.org>
This updates the pinned commit hash of the Gutenberg repository from `ea285b45692aed6c4f95353671393402f97f0aa7` to `b9743a015526ac8fd79298fd4e96cf002cee333b`. A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@ea285b4...b9743a0 - Style states: fix state deselection when selecting the already selected block (WordPress/gutenberg#81277) - Global styles: render element styles set only inside a breakpoint (WordPress/gutenberg#81265) - Style states: Fix phantom pseudo element style output (WordPress/gutenberg#81291) - Docs: remove breakpoint-only element style example from global styles guide (WordPress/gutenberg#81308) - theme.json schema: responsive states belong to blocks (WordPress/gutenberg#81253) - theme.json schema: allow responsive states on block style variations (WordPress/gutenberg#81309) - Render viewport state element styles in the editor (WordPress/gutenberg#81307) (WordPress/gutenberg#81311) - Site Editor: Decode HTML entities in Identity fields (WordPress/gutenberg#81269) (WordPress/gutenberg#81320) - Editor: Keep the canvas height stable while resizing the canvas (WordPress/gutenberg#81374) - Playlist: Normalize Waveform Player configuration handling (WordPress/gutenberg#81375) - Playlist: Improve audio conversion and track selection (WordPress/gutenberg#80926) (WordPress/gutenberg#81385) - fix: order site identity changes predictably (WordPress/gutenberg#81283) - Cover: Avoid passing null as the featured image size (WordPress/gutenberg#81444) - components/Menu: Restore Modal focus return when menu items close (WordPress/gutenberg#81446) - Notes: Fix text wrapping for long usernames in collaboration sidebar (WordPress/gutenberg#81406) - Site Editor: Use inverted ThemeProvider seed for portaled UI (WordPress/gutenberg#81296) Props wildworks. See #65529. Built from https://develop.svn.wordpress.org/branches/7.1@63209 git-svn-id: http://core.svn.wordpress.org/branches/7.1@62402 1a063a9b-81f0-0310-95a4-ce76da25c4cd
What?
The Cover block asks WordPress for the featured image using
nullas the image size. This PR passes'full'instead, which is what the code already ends up using anyway.This fixes the PHP 8.5 CI failures on
trunk.Why?
Passing
nullas an image size was never valid —get_the_post_thumbnail_url()expects a size name or a width/height array.PHP 8.5 now deprecates using
nullas an array key, and a recent WordPress change — r63177 — madeimage_constrain_size_for_editor()do exactly that kind of lookup with whatever size it is handed. The previous code never reached the lookup; the new one does. So our invalidnullstarted producing a deprecation notice, which PHPUnit reports as a test error:Whatever Core decides to do about r63177, passing
nullhere is our bug, so this is worth fixing on its own.How?
'full'was chosen over'post-thumbnail'because it keeps the output identical — passingnulltoday always resolves to the full-size image URL, and'full'does the same.The
<img>branch just above already uses'post-thumbnail'and is intentionally left alone — that one is a responsive image, not a CSS background.Testing Instructions
The failing test
Tests_Blocks_Render_Cover::test_gutenberg_render_block_core_coveralready covers this path, so green CI is the main check.To confirm nothing changed visually:
background-imageURL on.wp-block-cover__image-background. It should be the full-size image, the same as before this change.Use of AI Tools
Claude Code was used to track down the cause of the CI failure and to draft this description. The one-line change and the choice of
'full'were reviewed and accepted by me.