[wp-trac] [WordPress Trac] #37010: Remove early exits from `WP_Customize_Setting::validate()` on `WP_Error` or `null`

WordPress Trac noreply at wordpress.org
Fri Jun 3 05:24:43 UTC 2016


#37010: Remove early exits from `WP_Customize_Setting::validate()` on `WP_Error` or
`null`
-------------------------+-----------------------------
 Reporter:  dlh          |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Customize    |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Currently, `WP_Customize_Setting::validate()` returns immediately if
 `WP_Error` or `null` is passed to it.

 I wonder whether `validate()` could continue to the end of the method even
 for those values, including the `"customize_validate_{$setting_id}"`
 filter.

 Two reasons for this change would be:

 1. Currently, any `WP_Error` passed to `validate()` is assumed to have
 `errors` -- it isn't subject to the `empty()` check at the end of the
 method.

 2. It might be nice to be able to return `null` from
 `WP_Customize_Setting::sanitize()` for backwards compatibility but still
 add details about the error with the `'customize_validate_'` filter where
 it's supported.

 Patch attached with one approach to the change.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37010>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list