• As it stands, all it takes is one bad action or filter callback to mess up any action, many of which are very central to core functioning of WP.

    You can add an endless number of these, and every time you add a plugin or theme there’s a good chance there’s many contained within.

    Why not do something like this, so that an action or filter can recover from a badly written callback?

    do {
    		foreach ( (array) current($wp_filter[$tag]) as $the_ )
    			if ( !is_null($the_['function']) )
                                    try{
                                        call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
                                    } catch(Exception $e){
                                        continue;
                                    }
    	} while ( next($wp_filter[$tag]) !== false );

    plugin/theme authors still have the option to do their own error handling, but WP doesn’t assume they will, and it’s not as easy to break the system.

    Has this been discussed before? Couldn’t find much on google, trac, or forums, but it seems like a fairly obvious topic for discussion to me.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Try/Catch around do_action and apply_filters callback execution’ is closed to new replies.