Skip to content

chore: remove always-true conditionals in gutenberg_register_shadow_support() - #68398

Merged
westonruter merged 3 commits into
WordPress:trunkfrom
justlevine:chore/always-true-gutenberg_register_shadow_support
Oct 25, 2026
Merged

westonruter merged 3 commits into
WordPress:trunkfrom
justlevine:chore/always-true-gutenberg_register_shadow_support

Conversation

@justlevine

Copy link
Copy Markdown
Contributor

What?

This PR removes the unnecessary $has_shadow_support from the conditional checks inside gutenberg_register_shadow_support(), as the function already early-returns if $has_shadow_support is falsey.

Why?

While this issue was surfaced by PHPStan (via #66693) it can be remediated independently as part of #66598

How?

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@justlevine
justlevine force-pushed the chore/always-true-gutenberg_register_shadow_support branch from 2509249 to 0f9485b Compare April 18, 2025 22:59
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fix is being brought to core in WordPress/wordpress-develop#14862,
along with the related PHPStan fixes from three other Gutenberg PRs, which
share this entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@westonruter westonruter added [Type] Code Quality Issues or PRs that relate to code quality Needs PHP backport Needs PHP backport to Core labels Oct 25, 2026
@westonruter

Copy link
Copy Markdown
Member

🤖 Comment by Claude Opus 5.5

trunk was merged in, and a backport changelog entry was added for WordPress/wordpress-develop#14862, which brings this and three related PHPStan fixes to core under Core-65817.

In core, the conditions in wp_register_shadow_support() are not merely redundant: since r56046 both array_key_exists() checks have lacked the !. A block type with shadow support but no style or shadow attribute never had them registered, while one that already defined them had its definitions replaced, dropping any default. The core PR adds the negation, so core matches Gutenberg, and adds tests for the attribute registration.

@github-actions

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

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: justlevine <justlevine@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@westonruter
westonruter merged commit 8a0ce0c into WordPress:trunk Oct 25, 2026
79 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 25, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Oct 26, 2026
These fixes were made in Gutenberg while resolving the PHPStan errors in the plugin, ahead of adding PHPStan to its CI, and are brought to core to keep the two codebases in sync. They were developed in:

* WordPress/gutenberg#68398
* WordPress/gutenberg#68404
* WordPress/gutenberg#68405
* WordPress/gutenberg#68407

The first one fixes a bug in core. Since r56046 the `array_key_exists()` checks in `wp_register_shadow_support()` have lacked their negation, so a block type with shadow support but no `style` or `shadow` attribute never had them registered, while one that already defined them had its definitions replaced, dropping any `default`. Gutenberg already had the negation. Tests are added for the attribute registration.

The others make implicit type conversions explicit in the layout and duotone code, and narrow the types used by `WP_Theme_JSON::get_feature_declarations_for_node()` so that it reports no errors even at PHPStan rule level 10. Since the node comes from `theme.json` data, that method now also checks that a feature is an array before reading its subfeatures. This fixes a fatal error ("Cannot unset string offsets") when a feature's value is a string, such as a `shadow`, and the block's selectors for that feature are a list rather than keyed by subfeature name, since each numeric key then reads a character of the string instead of a subfeature. The baseline entries for the resolved errors are removed.

Developed in #14862.
Follow-up to r56046, r56058, r56101, r62478, r63426.

Props justlevine, westonruter, poena, ramonopoly.
See #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@64727 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 26, 2026
These fixes were made in Gutenberg while resolving the PHPStan errors in the plugin, ahead of adding PHPStan to its CI, and are brought to core to keep the two codebases in sync. They were developed in:

* WordPress/gutenberg#68398
* WordPress/gutenberg#68404
* WordPress/gutenberg#68405
* WordPress/gutenberg#68407

The first one fixes a bug in core. Since r56046 the `array_key_exists()` checks in `wp_register_shadow_support()` have lacked their negation, so a block type with shadow support but no `style` or `shadow` attribute never had them registered, while one that already defined them had its definitions replaced, dropping any `default`. Gutenberg already had the negation. Tests are added for the attribute registration.

The others make implicit type conversions explicit in the layout and duotone code, and narrow the types used by `WP_Theme_JSON::get_feature_declarations_for_node()` so that it reports no errors even at PHPStan rule level 10. Since the node comes from `theme.json` data, that method now also checks that a feature is an array before reading its subfeatures. This fixes a fatal error ("Cannot unset string offsets") when a feature's value is a string, such as a `shadow`, and the block's selectors for that feature are a list rather than keyed by subfeature name, since each numeric key then reads a character of the string instead of a subfeature. The baseline entries for the resolved errors are removed.

Developed in WordPress/wordpress-develop#14862.
Follow-up to r56046, r56058, r56101, r62478, r63426.

Props justlevine, westonruter, poena, ramonopoly.
See #65817.

Built from https://develop.svn.wordpress.org/trunk@64727


git-svn-id: http://core.svn.wordpress.org/trunk@63877 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@ingeniumed ingeniumed added the [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi label Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Needs PHP backport Needs PHP backport to Core [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants