WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15428 closed defect (bug) (invalid)

wp_die() filter broken, doesn't pass args

Reported by: somatic Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.1
Component: General Keywords: wp_die
Focuses: Cc:

Description

There is a filter to manipulate the output of wp_die(), but it is setup incorrectly. When you hook it, the only arg that is passed is the name of the default handler function, which renders the filter useless, as you can't manipulate the message, title, and other display output.

Here's the fix:

wp-includes/functions.php, line 2661

current:

$function = apply_filters( 'wp_die_handler', '_default_wp_die_handler');

fix:

$function = apply_filters( 'wp_die_handler', $message, $title, $args);

Change History (5)

comment:1 @nacin5 years ago

That wouldn't allow you to modify the title or args.

The point of the filter is to modify the function callback, which will then allow you to have full pluggable control.

comment:2 @scribu5 years ago

It's an odd way to do it.

I think it should be transformed into an action and have '_default_wp_die_handler' hooked to it.

comment:3 @scribu5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Nevermind. Not worth the back-compat hassle.

comment:4 @nacin5 years ago

We can add a pre_wp_die hook. I see some good use cases for that.

comment:5 @westi5 years ago

The reason it is a filter and not an action is we only want one thing to be called.

I'm not convinced a filter should be made available to filter the message/title/args of wp_die.

If you want to do that you can just add you own handler.

Your handler can still call the default function.

Note: See TracTickets for help on using tickets.