Opened 9 years ago
Closed 9 years ago
#39770 closed defect (bug) (fixed)
Customize: Client-side notification error is unexpectedly cleared when no corresponding server-side validation
| Reported by: | westonruter | Owned by: | westonruter |
|---|---|---|---|
| Priority: | low | Milestone: | 4.7.4 |
| Component: | Customize | Version: | 4.6 |
| Severity: | normal | Keywords: | has-patch commit fixed-major |
| Cc: | Focuses: |
Description
Setting validation can be added both by adding a validate_callback (or sanitize_callback) on the server, or it can be added by adding an error Notification via JS (see also Make/Core post):
wp.customize( 'blogdescription', function( setting ) { var errorCode = 'capital_P_dangit'; setting.bind( function( value ) { var notification; if ( /[Ww]ordpress/.test( value ) ) { notification = new wp.customize.Notification( errorCode, { type: 'error', message: 'Capital P Dangit!' } ); setting.notifications.add( errorCode, notification ); } else { setting.notifications.remove( errorCode ); } } ); } );
However, if the server lacks corresponding validation (which normally it should) the setting is currently marked as valid on the server and the error gets unexpectedly cleared on the client.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
In order for returning an error/notification to work properly, api._handleSettingValidities needs to only remove notification errors that are no longer valid which are
fromServer. See 39770.0.diff.