[wp-trac] [WordPress Trac] #32103: Customizer sanitizes data multiple times when options are served as Serialized Settings
WordPress Trac
noreply at wordpress.org
Sat Oct 3 14:08:36 UTC 2015
#32103: Customizer sanitizes data multiple times when options are served as
Serialized Settings
-------------------------------------+-------------------------------------
Reporter: Air. | Owner: westonruter
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 4.4
Component: Customize | Version: 3.4
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: administration,
reporter-feedback | performance
-------------------------------------+-------------------------------------
Comment (by wpweaver):
There should not be a scalability issue. We are talking 600, not 6
million.
But if you haven't figured this out, here is what I'm pretty sure is the
issue in preview().
{{{
public function preview() {
if ( ! isset( $this->_original_value ) ) {
$this->_original_value = $this->value();
}
if ( ! isset( $this->_previewed_blog_id ) ) {
$this->_previewed_blog_id = get_current_blog_id();
}
switch( $this->type ) {
case 'theme_mod' :
add_filter( 'theme_mod_' . $this->id_data[
'base' ], array( $this, '_preview_filter' ) );
break;
case 'option' :
if ( empty( $this->id_data[ 'keys' ] ) )
/* PROBLEM */ add_filter( 'pre_option_'
. $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
else {
/* PROBLEM */ add_filter( 'option_' .
$this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
/* PROBLEM */ add_filter(
'default_option_' . $this->id_data[ 'base' ], array( $this,
'_preview_filter' ) );
}
break;
default :
...
}}}
I added the /* PROBLEM */ comments. What do these statements really mean?
The problem is that the array( $this, '_preview_filter') is creating a
brand new filter for EACH option setting. Given that the serialized theme
option setting is IDENTICAL for all, there really needs to be only a
single filter.
The effect is that for '''each''' setting that is looked up (filtered), it
will be run through '''N''' filters, where '''N''' is the total number of
settings. So if there are 600 settings, '''each''' of those settings will
be run through 600 filters, each identical to the other. So, the process
is 600 * 600 operations instead of a needed 600 only. That's the problem.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32103#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list