[wp-trac] [WordPress Trac] #30937: Add Customizer state persistence in changesets (formerly “transactions”)
WordPress Trac
noreply at wordpress.org
Mon Oct 17 05:15:05 UTC 2016
#30937: Add Customizer state persistence in changesets (formerly “transactions”)
-------------------------------------------------+-------------------------
Reporter: westonruter | Owner:
Type: feature request | westonruter
Priority: high | Status: assigned
Component: Customize | Milestone: 4.7
Severity: normal | Version:
Keywords: has-patch needs-testing needs-unit- | Resolution:
tests | Focuses:
-------------------------------------------------+-------------------------
Comment (by westonruter):
On Friday I realized a serious performance problem with how changesets
were implemented. Which is now obvious to me now, the approach of trying
to update the `customize_changeset` post every time (debounced 250ms) that
a setting is updated will hammer the MySQL database with writes. DB writes
are very slow compared with reads. What's even worse is that the HTTP
request being made to update the changeset was blocking both the full
refresh request and the selective refresh request, resulting in a
customizer preview that was at least twice as slow.
The solution to the performance problem is to return to using a `POST`
request for previewing changes when the changeset is not yet updated in
the DB. Instead of doing an Ajax `POST` request and then using
`document.write()` into an iframe, the patch instead creates a temporary
form and sets the `target` window for the form to be iframe. This ensures
that the document in the iframe will run in the context of the expected
URL, and it will also allow us to amend the customized state with any
unsaved setting values that have yet to be persisted into the changeset.
So also with this change, the changeset is now auto-saved at the
`AUTOSAVE_INTERVAL` and also whenever a `blur` event is triggered on the
customizer window.
Full writeup on the problem and solution can be seen here:
https://github.com/xwp/wordpress-develop/issues/170
These changes and others made over the weekend: https://github.com/xwp
/wordpress-develop/pull/161/files/c09a0eb..0753db3
* [https://github.com/xwp/wordpress-develop/pull/161/commits/27ae83c
27ae83c] Eliminate updating changeset with every change in favor of
autosave polling
* [https://github.com/xwp/wordpress-develop/pull/161/commits/b4ff52c
b4ff52c] Remove marking of changeset-saved settings as clean, missed in
58b31cf
* [https://github.com/xwp/wordpress-develop/pull/161/commits/1c82e40
1c82e40] Only increment setting revision for added setting if it is
initially dirty
* [https://github.com/xwp/wordpress-develop/pull/161/commits/0be8eca
0be8eca] Introduce wp.customize.dirtyValues method; replace
excludeCustomized with excludeCustomizedSaved option for previewer.query()
* [https://github.com/xwp/wordpress-develop/pull/161/commits/5f5056d
5f5056d] Short-circuit changeset update request if there are no pending
changes
* [https://github.com/xwp/wordpress-develop/pull/161/commits/2fc8ec8
2fc8ec8] Populate iframe window via form submitting post request with
unsaved values instead of just src to URL with changeset UUID
* [https://github.com/xwp/wordpress-develop/pull/161/commits/2cb33f3
2cb33f3] Clarify that PreviewFrame.uuid() does not return an actual UUID
* [https://github.com/xwp/wordpress-develop/pull/161/commits/7b94257
7b94257] Remove obsolete reference to Previewer.request
* [https://github.com/xwp/wordpress-develop/pull/161/commits/8f0bede
8f0bede] Only update lastSavedRevision when changeset update successful
* [https://github.com/xwp/wordpress-develop/pull/161/commits/469ffed
469ffed] Vastly simplify requestChangesetUpdate now that debouncing and
request locking removed
* [https://github.com/xwp/wordpress-develop/pull/161/commits/7f97497
7f97497] Restore sending settingValidities and _dirty in full refresh
* [https://github.com/xwp/wordpress-develop/pull/161/commits/838e415
838e415] Request changeset update when customizer window hidden or before
unloaded
* [https://github.com/xwp/wordpress-develop/pull/161/commits/13b89d4
13b89d4] Remove provision for plugins including customize_changeset on
export screen for now
* [https://github.com/xwp/wordpress-develop/pull/161/commits/86eec4b
86eec4b] Fix _wp_scripts_maybe_doing_it_wrong in
WP_Customize_Manager::wp_die()
* [https://github.com/xwp/wordpress-develop/pull/161/commits/1794d2f
1794d2f] Use GET and POST query vars instead of REQUEST when bootstrapping
customizer
* [https://github.com/xwp/wordpress-develop/pull/161/commits/5d5a529
5d5a529] Rewrite Ajax GET requests to be POST requests with customized
state data included
* [https://github.com/xwp/wordpress-develop/pull/161/commits/21f6bf3
21f6bf3] Use AUTOSAVE_INTERVAL as changesetAutoSave
* [https://github.com/xwp/wordpress-develop/pull/161/commits/ae5a980
ae5a980] Add data-src attribute to iframe to facilitate debugging
* [https://github.com/xwp/wordpress-develop/pull/161/commits/70c52ce
70c52ce] Add data-src attribute to iframe to facilitate debugging
* [https://github.com/xwp/wordpress-develop/pull/161/commits/8b3c3df
8b3c3df] Ensure that changeset is updated prior to theme preview switch;
eliminate replaceState requirement and AYS dialog
* [https://github.com/xwp/wordpress-develop/pull/161/commits/f53f8f7
f53f8f7] Use window blur instead of page visibility hidden to trigger save
* [https://github.com/xwp/wordpress-develop/pull/161/commits/4df7928
4df7928] Prevent background changeset update if another is currently in
progress
* [https://github.com/xwp/wordpress-develop/pull/161/commits/a6cd0f2
a6cd0f2] Remove unnecessary stateQueryParams setting
* [https://github.com/xwp/wordpress-develop/pull/161/commits/63e16e2
63e16e2] Clarify when a customize_save request is transactional and allows
revisions
* [https://github.com/xwp/wordpress-develop/pull/161/commits/7e5fa46
7e5fa46] Remove todos
* [https://github.com/xwp/wordpress-develop/pull/161/commits/9273c08
9273c08] Add object caching for changeset UUID to post ID lookup
* [https://github.com/xwp/wordpress-develop/pull/161/commits/ea7d3e9
ea7d3e9] Load preview via iframe[src] if no unsaved dirty changes;
otherwise, use form post request into window
* [https://github.com/xwp/wordpress-develop/pull/161/commits/f222717
f222717] Skip incrementing processing state if requestChangesetUpdate will
short-circuit
* [https://github.com/xwp/wordpress-develop/pull/161/commits/f265835
f265835] Prevent date from being cleared in wp_update_post call
* [https://github.com/xwp/wordpress-develop/pull/161/commits/cf91851
cf91851] Allow date formats accepted by strtotime in customize_save
requests
* [https://github.com/xwp/wordpress-develop/pull/161/commits/9d615b8
9d615b8] Add link to start new customizer session when wp_die'd due to
already-published changeset
* [https://github.com/xwp/wordpress-develop/pull/161/commits/9ab8c26
9ab8c26] Ensure save & publish button is disabled immediately once there
are unsaved changes
* [https://github.com/xwp/wordpress-develop/pull/161/commits/3cc1ea8
3cc1ea8] Break up methods to improve testability
* [https://github.com/xwp/wordpress-develop/pull/161/commits/0753db3
0753db3] Ensure changeset_status is returned as publish when sending
future with non-future date
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30937#comment:75>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list