[wp-trac] [WordPress Trac] #28319: Add hook to WP_Error for logging and report purposes
WordPress Trac
noreply at wordpress.org
Wed Jul 9 14:28:56 UTC 2014
#28319: Add hook to WP_Error for logging and report purposes
--------------------------+--------------------------
Reporter: ebinnion | Owner: johnbillion
Type: enhancement | Status: reopened
Priority: normal | Milestone: 4.0
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: dev-feedback | Focuses:
--------------------------+--------------------------
Changes (by kovshenin):
* keywords: has-patch dev-feedback commit => dev-feedback
* status: closed => reopened
* resolution: fixed =>
Comment:
Don't you think this would be more useful if the action ran on `add()` and
the class constructor used `add()` to set the first error, if any? That
would allow to track multiple errors when they're added to the error
object at a later stage:
{{{
$errors = new WP_Error();
if ( foo_condition() )
$errors->add( 'foo', 'A foo error has occurred.' );
if ( bar_condition() )
$errors->add( 'bar', 'A bar error has occurred.' );
// Any of the above conditions failed?
if ( ! empty( $errors->get_error_codes() ) )
return $errors;
// Keep going
}}}
With the code above and the change in r29033, the create_wp_error action
is never fired, even though two errors could have occurred.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28319#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list