Make WordPress Core

Opened 4 hours ago

Last modified 2 hours ago

#66274 new defect (bug)

wp_get_state_style_with_fallback_dimension_styles unused since WP 7.1.2

Reported by: marian1 Owned by:
Priority: normal Milestone: 7.2
Component: Editor Version:
Severity: trivial Keywords: needs-patch
Cc: Focuses:

Description

wp_get_state_style_with_fallback_dimension_styles() was introduced in WP 7.1. The only call to it was removed in WP 7.1.2.

The function should either be removed, deprecated, or receive a comment explaining why it remains undeprecated despite no longer being used.

Change History (2)

This ticket was mentioned in ​PR #14121 on ​WordPress/wordpress-develop by ​@abditsori.


3 hours ago
#1

  • Keywords has-patch has-unit-tests added

https://core.trac.wordpress.org/ticket/66274

Summary

wp_get_state_style_with_fallback_dimension_styles() was introduced in ​6152d85efd ("Editor: add support for aspect ratio and related controls in viewport states"). Its only call site was removed in a later refactor, ​1caffb5277 ("Editor: fix responsive element styles front end output.", fixes #65164), when the inline logic that called it was replaced by a new wp_add_block_state_style_rule() helper that doesn't call it.

Since then the function has had zero callers anywhere in core, confirmed via:

grep -rn "wp_get_state_style_with_fallback_dimension_styles" src/

which only matches its own definition.

Changes

  • Removed wp_get_state_style_with_fallback_dimension_styles() from wp-includes/block-supports/states.php.
  • Removed its three dedicated unit tests (test_adds_fallback_dimension_styles_for_aspect_ratio, test_does_not_add_fallback_dimension_styles_for_default_aspect_ratio, test_adds_fallback_aspect_ratio_style_for_height) from tests/phpunit/tests/block-supports/states.php.
  • Verified wp_is_explicit_aspect_ratio_value() (used inside the removed function) is still called elsewhere in block-supports/dimensions.php, so it was left untouched.

Test plan

  • [x] php -l on both changed files.
  • [x] Confirmed no remaining references to the removed function anywhere in the codebase.
  • [x] Ran tests/phpunit/tests/block-supports/states.php — 43 tests, 69 assertions, all passing.

#2 @westonruter
2 hours ago

  • Keywords needs-patch added; has-patch has-unit-tests removed
  • Milestone Awaiting Review → 7.2

There are no uses in plugins on the directory: ​https://veloria.dev/search/f7ec6f89-c665-4c26-b049-2b78f62decc6

Same for themes: ​https://veloria.dev/search/a0a3702f-9890-4b25-976a-5162b1eb1dc0

That said, moving to deprecated.php is safer.

Note: See TracTickets for help on using tickets.