Repository navigation
Conversation
|
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. |
There was a problem hiding this comment.
🟡 Changes recommended
The tests override inherited die handling in a way that can let execution continue unexpectedly and lack assertions for nonce rejection and redirect destinations.
2 open issues
What changed in this PR
Adds PHPUnit coverage for WordPress’s set_screen_options() function under Trac ticket #65183, without changing production code.
Changes:
- Tests saving standard per-page options and filter-enabled custom and layout options.
- Covers absent POST data and rejection of values above 999.
- Adds request setup and redirect interception for save-path tests.
| File | Description |
|---|---|
tests/phpunit/tests/admin/includes/misc/setScreenOptions.php |
Adds screen-option persistence tests, input datasets, and filter callbacks. |
Review effort: Balanced
| $_SERVER['HTTP_REFERER'] = admin_url( 'edit.php?pagenum=2' ); | ||
| $_POST['screenoptionnonce'] = wp_create_nonce( 'screen-options-nonce' ); | ||
| $_REQUEST['screenoptionnonce'] = $_POST['screenoptionnonce']; | ||
| $_REQUEST['_wp_http_referer'] = $_SERVER['HTTP_REFERER']; |
| public function wp_die_handler( $message = '', $title = '', $args = array() ) { | ||
| return array( $this, 'die_handler' ); |
lancewillett
left a comment
There was a problem hiding this comment.
Please address the existing Copilot finding about wp_die_handler(): the parent test class already registers get_wp_die_handler(), which selects $this->wp_die_handler as the terminal handler. This override returns another callback instead of throwing, so it changes that inherited contract. Remove the custom die-handler override/registration and use the inherited WPDieException behavior.
The check_admin_referer hook also cannot bypass nonce validation; its return value is ignored. These requests already supply valid nonces, so those callbacks can be removed. Keep the assertions on saved/rejected user metadata.
Randomized local single-site and multisite checks pass, as do lint and coding standards. The old CI log has expired and GitHub rejects its rerun, so please also refresh against trunk for a current run.
AI review · gpt-6

Description:
This PR adds unit tests for the
set_screen_options()function inwp-admin/includes/misc.php. These tests ensure that the function correctly saves screen options (like items per page) for the current user, handles non-standard options via filters, and correctly validates input ranges.The tests cover:
_per_pageoptions.set-screen-optionfilter.layout_columnsoptions.$_POSTdata.Trac ticket: https://core.trac.wordpress.org/ticket/65183
AI Disclosure: