Make WordPress Core

Opened 3 years ago

Closed 9 months ago

Last modified 8 months ago

#60886 closed enhancement (fixed)

wp_trigger_error() has no action or filter to always run like wp_doing_it_wrong has

Reported by: kkmuffme Owned by: audrasjb
Priority: normal Milestone: 7.0
Component: General Version:
Severity: trivial Keywords: has-patch commit needs-dev-note
Cc: Focuses:

Description

While there is e.g. wp_doing_it_wrong_run that will always run, the hooks in wp_trigger_error() are after validating WP_DEBUG
Therefore there is no way to hook onto it/get those errors from a plugin if WP_DEBUG isn't true.

Sometimes you don't/can't enable debug or want to only get errors for specific callers.

Change History (10)

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


3 years ago
#1

  • Keywords has-patch added

This ticket was mentioned in ​Slack in #core by kkmuffme. ​View the logs.


3 years ago

This ticket was mentioned in ​Slack in #core by kkmuffme. ​View the logs.


3 years ago

This ticket was mentioned in ​Slack in #core by mikachan. ​View the logs.


2 years ago

#5 @swissspidy
11 months ago

  • Milestone Awaiting Review → 7.0

This would be useful for WP-CLI as well.

It would also help to make currently pointless code like ​https://github.com/WordPress/wordpress-develop/blob/6045c24efe16f3685c40ed9cac147ff22d5c65d2/src/wp-admin/includes/translation-install.php#L83 make sense.

​@audrasjb commented on ​PR #6345:


9 months ago
#6

I refreshed since tags

#7 @audrasjb
9 months ago

  • Keywords commit added

Looks good to me. I'm self assigning it for commit.

#8 @audrasjb
9 months ago

  • Owner set to audrasjb
  • Resolution → fixed
  • Status new → closed

In 61688:

General: Allow to hook into wp_trigger_error() when WP_DEBUG is not truthy.

This changeset allow developers to attach custom error handlers into wp_trigger_error() even if WP_DEBUG is not truthy.
It introduces two new hooks, making wp_trigger_error() consistent with what is available in _doing_it_wrong:

  • wp_trigger_error_always_run always fires when the given function triggers a user-level error/warning/notice/deprecation message.
  • wp_trigger_error_trigger_error filters whether to trigger the error.

Props kkmuffme, swissspidy, audrasjb.
Fixes #60886.

#10 @audrasjb
8 months ago

  • Keywords needs-dev-note added

This deserves a specific dev note, I think.

Note: See TracTickets for help on using tickets.