Repository navigation
Conversation
Assign the Live Preview link instead of appending to an action that is not set, and add a test.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@propsbot refresh |
This resolves one of the four default
offsetAccess.notFoundPHPStan errors, inWP_Themes_List_Table::display_rows(), and removes its entry from the baseline. The other three entries, inclass-wp-site-health.phpandfonts.php, are left in the baseline.The error
display_rows()builds the theme action links in$actions, and for users who can customize it adds the Live Preview link with$actions['preview'] .= sprintf( ... ). Thepreviewkey has not been set at that point, so PHPStan reportsOffset 'preview' does not exist on array{activate: non-falsy-string}. This is a real bug: the.=reads the missing key first, which raisesUndefined array key "preview"on PHP 8 (a notice on PHP 7) every time the Live Preview link is printed.The fix
The line now assigns the link with
=instead of appending with.=. Behavior is unchanged apart from the warning: appending to a missing key already produced the link on its own, so$actions['preview']holds the same string and thetheme_action_linksfilters receive the same array. The line has been this way since at least r25001.A test,
test_themes_list_table_display_rows_prints_live_preview_link(), prints the rows for an administrator and checks that the Live Preview link is there. It errors withUndefined array key "preview"without the fix and passes with it.Testing
composer phpstan:defaultandcomposer phpstan:strictreport no errors.composer phpstan:baselines -- --identifier=offsetAccess.notFoundreports no errors, and only theclass-wp-themes-list-table.phpentry is removed.class-wp-themes-list-table.phpandwpListTable.php.tests/phpunit/tests/admin/wpListTable.phppasses (75 tests, the same 4 PHPUnit deprecation warnings as ontrunk).Trac ticket: https://core.trac.wordpress.org/ticket/66739
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.