Repository navigation
65655 functions wp die - #12571
65655 functions wp die#12571pbearne wants to merge 9 commits into
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:
|
Refactor wp_die_handler filter for better readability.
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 only verify that filters run, leaving incorrect default or Ajax handler selection and missing Ajax callback execution undetected.
2 open issues
What changed in this PR
This PR adds focused PHPUnit coverage for WordPress’s wp_die() dispatch logic and default HTML error handler, supporting ticket #65655 without changing production code.
Changes:
- Adds tests for standard and Ajax handler selection and forwarding
WP_Errorobjects. - Adds HTML output checks for error messages, titles, additional errors, and action links.
| File | Description |
|---|---|
tests/phpunit/tests/wp-includes/functions/WpDieTest.php |
Tests handler selection and forwarding error objects. |
tests/phpunit/tests/functions/_defaultWpDieHandler.php |
Tests the default handler’s HTML output and links. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
lancewillett
left a comment
There was a problem hiding this comment.
Please run the Ajax dispatch case in-process when relocating the test. wp_die() calls wp_doing_ajax(), so add_filter( 'wp_doing_ajax', '__return_true' ); exercises the real handler selection without defining DOING_AJAX or using either process-isolation annotation. I tried it with the same callback and output assertions: it passed in randomized single-site and multisite runs. The base class restores the filter after the test.
AI review · gpt-6

This PR introduces dedicated unit tests for the wp_die() function and its primary HTML handler _default_wp_die_handler() in wp-includes/functions.php.
Following the project's testing guidelines, the tests are split into two files:
•tests/phpunit/tests/functions/wpDie.php: Focuses on handler selection logic (Standard vs. Ajax), handling of WP_Error objects, and ensuring the correct callback is triggered via filters.
•tests/phpunit/tests/functions/_defaultWpDieHandler.php: Verifies the HTML output generated by the default handler, including the error message, title, additional error lists, and action links.
The tests use WPDieException to intercept execution termination and MockAction to verify filter interactions.
Trac ticket: https://core.trac.wordpress.org/ticket/65655
AI Disclosure:
•AI assistance: Yes
•Tool(s): Junie (JetBrains)
•Model(s): gemini-3-flash-preview
•Used for: Code analysis, test implementation, and workflow management.