[wp-trac] [WordPress Trac] #32103: Customizer sanitizes data multiple times when options are served as Serialized Settings

WordPress Trac noreply at wordpress.org
Sun Sep 27 06:39:05 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-    |     Focuses:  administration, performance
  testing                       |
--------------------------------+------------------------------------------
Changes (by westonruter):

 * keywords:  needs-patch => has-patch needs-testing


Comment:

 I've scrapped the approach I was taking in [attachment:32103.wip.diff],
 and I've come up with a much more concise solution that should also
 improve performance for previewing non-multidimensional (unserialized)
 settings as well.

 Please see [attachment:32103.diff].

 The key change here is that the `WP_Customize_Setting::preview()` method
 now checks whether there has been a value saved for that setting
 previously (e.g. if the option or theme mod already is set) and also if
 the setting has a post value associated with it (i.e. it is `dirty`). If
 the setting has already has a value set and it is not dirty, then the
 `preview` method just short-circuits and prevents adding any filters at
 all since there is no change to apply.

 I'm seeing great performance improvements with this change. My test site
 has 100 widgets.

 Before:
 * Preview render time: 0.5 seconds
 * Number of preview filters added: 132
 * Calls to `WP_Customize_Setting::multidimensional_replace()`: 20,431 (!!)

 After:
 * Preview render time: 0.35 seconds (30% reduction)
 * Number of preview filters added: 13 (90% reduction)
 * Calls to `WP_Customize_Setting::multidimensional_replace()`: 4 (99.98%
 reduction!!)

 Please test!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32103#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list