[wp-trac] [WordPress Trac] #35451: Customizer: aggregated multidimensional settings overwrite changes made outside the Customizer
WordPress Trac
noreply at wordpress.org
Wed Jan 13 22:39:58 UTC 2016
#35451: Customizer: aggregated multidimensional settings overwrite changes made
outside the Customizer
--------------------------+-----------------------------
Reporter: mattwiebe | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: 4.4
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
4.4's aggregated multidimensional settings naïvely assumes that no other
code will touch the root setting, but that's not necessarily true. Here's
some pseudo code from WP.com:
{{{
$wp_customize->add_setting( 'custom_colors[colors]', array(
'sanitize_callback' => 'wpcom_sanitize_colors'
) );
function wpcom_sanitize_colors( $colors ) {
// do some sanitization
// update the CSS used to output colors
$opts = get_option( 'custom_colors', array() );
$opts['css'] = wpcom_create_css_for_colors( $colors );
update_option( 'custom_colors', $opts );
return $colors;
}
}}}
Unfortunately, the new aggregated multidimensional setting code assumes
that the Customizer is the only thing that might make a setting change in
WP and blindly overwrites the base option/theme_mod. In the above code,
the `css` member will either reflect outdated colors, or not be set at
all.
What should probably happen is that the root value should be freshly
grabbed in `set_root_value()` and `array_merge`'d with the current
aggregate. Or maybe that code should be in `update()`? In any case, this
broke a few things on WP.com when we finally started pushing out 4.4 code.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35451>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list