Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#39770 closed defect (bug) (fixed)

Customize: Client-side notification error is unexpectedly cleared when no corresponding server-side validation

Reported by: westonruter's profile westonruter Owned by: westonruter's profile westonruter
Milestone: 4.7.4 Priority: low
Severity: normal Version: 4.6
Component: Customize Keywords: has-patch commit fixed-major
Focuses: Cc:

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.

Attachments (1)

39770.0.diff (665 bytes) - added by westonruter 8 years ago.

Download all attachments as: .zip

Change History (11)

@westonruter
8 years ago

#1 @westonruter
8 years ago

  • Keywords has-patch added

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.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


8 years ago

#3 @westonruter
8 years ago

  • Milestone changed from 4.7.3 to 4.7.4

This ticket was mentioned in Slack in #core by swissspidy. View the logs.


8 years ago

This ticket was mentioned in Slack in #core by swissspidy. View the logs.


8 years ago

#6 @swissspidy
8 years ago

  • Owner set to westonruter
  • Status changed from new to assigned

@westonruter Is this ready for a commit?

#7 @westonruter
8 years ago

  • Keywords commit added

#8 @westonruter
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 40319:

Customize: Prevent client-side validation from being cleared when no corresponding server-side validation is present.

See #36944.
Fixes #39770.

#9 @westonruter
8 years ago

  • Keywords fixed-major added
  • Priority changed from normal to low
  • Resolution fixed deleted
  • Status changed from closed to reopened

Re-opening for consideration in 4.7.4.

#10 @swissspidy
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 40345:

Customize: Prevent client-side validation from being cleared when no corresponding server-side validation is present.

See #36944.
Fixes #39770.

Merges [40319] to the 4.7 branch.

Note: See TracTickets for help on using tickets.