Opened 12 years ago
Closed 12 years ago
#20833 closed defect (bug) (fixed)
Settings API notices/errors can get lost by checking for errors for a specific setting
Reported by: | kobenland | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Administration | Keywords: | has-patch |
Focuses: | Cc: |
Description
When using the Settings API, setting errors are saved in a transient to be available after redirection.
After the redirect, when a plugin now checks for errors:
<?php //by checking get_settings_errors( 'settings-name' ); // or displaying settings_errors( 'settings-name' );
any existing errors retrieved from the transient gets lost, because they share the same variable and every error that does not match the requested setting gets unset.
Attachments (2)
Change History (7)
#1
@
12 years ago
- Settings error is saved by the Settings API in the
'settings_error'
transient. - On next page-load (redirected back to the original settings page)
settings_errors()
gets called, looking for errors to a specific setting. - Since
$_GET['settings-updated'
is set, the transient gets pulled into the temporary variable$settings_errors
and then deleted (all other errors, previously added byadd_settings_error()
, also get merged into the$settings_errors
variable) - Errors to a specific setting are requested, so
$settings_errors
get looped through, unsetting every error that does not belong to the requested setting. Including the ones from the transient.
Patch merges the errors into the global $wp_settings_errors
variable, making them available through multiple calls to settings_errors()
.
Patch also returns only the requested errors, without unsetting all others.
#3
@
12 years ago
- Owner set to ryan
- Resolution set to fixed
- Status changed from new to closed
In [21315]:
Note: See
TracTickets for help on using
tickets.
Make sure errors from transient get added to the global variable and not unset when checking for an error of a specific setting. Also always return an array, as noted in the documentation.