Skip to content

65655 functions wp die - #12571

Open
pbearne wants to merge 9 commits into
WordPress:trunkfrom
pbearne:65655-functions-wp_die
Open

pbearne wants to merge 9 commits into
WordPress:trunkfrom
pbearne:65655-functions-wp_die

Conversation

@pbearne

@pbearne pbearne commented Jul 16, 2026 •

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

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:

Props pbearne, mukesh27.

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.

Refactor wp_die_handler filter for better readability.
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_Error objects.
  • 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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the added tests covering wp_die() dispatch and default HTML error handling.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@pbearne
pbearne requested a review from lancewillett November 5, 2026 17:52

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants