[wp-trac] [WordPress Trac] #32202: Add support for options page locking (settings API concurrency)

WordPress Trac noreply at wordpress.org
Fri May 15 18:57:53 UTC 2015


#32202: Add support for options page locking (settings API concurrency)
--------------------------------+------------------------------
 Reporter:  westonruter         |       Owner:
     Type:  enhancement         |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Options, Meta APIs  |     Version:  3.6
 Severity:  normal              |  Resolution:
 Keywords:  needs-patch         |     Focuses:  administration
--------------------------------+------------------------------

Comment (by daxelrod):

 Attached a generic edit locking concept for core. Roughly extends the API
 for post_locks and could serve as a base for settings page or customizer
 locking. The edit locks leverage *meta tables for comments, posts, and
 users; sitemeta table (type = 'site') for multisite; and options for
 everything else. The {{{$type}}} and {{{$id}}} parameters are purposefully
 not limited as to allow developers edit lock capabilities on their own
 settings pages.

 Basic API:

 {{{
 wp_get_edit_lock( $type, $id ); // Retrieves the edit lock if it exists
 wp_check_edit_lock( $type, $id ); // Checks if the object is being edited
 by another user
 wp_set_edit_lock( $type, $id, $time, $user_id ); // Mark an object as
 being edited.
 }}}

 Introduced some helper functions for consistent handling of locks:

 {{{
 wp_read_edit_lock( $lock ); // Splits apart edit lock into time and
 user_id
 wp_create_edit_lock( $time, $user_id ); // Packs time and user_id into an
 edit lock string
 }}}

 Introduced 2 new filters:

 {{{
 add_filter('allow_edit_lock', function ( $allow, $type, $id ) {}, 10, 3);
 // Control over if edit locks are allowed
 add_filter('wp_edit_' . $type . '_lock_window', function ( $time_window )
 {}); // Control over duration of edit lock for a particular type.
 }}}

 It has full compatibility with existing post_locks and those existing
 functions now proxy the new edit_lock API.

 If this is desirable for core, the next step would be to make a generic
 version of the locking UI (This XXX is currently locked by YYY) so visual
 feedback for edit locks can be applied in other contexts (i.e. settings
 pages, customizer, etc.). We have set up a small demo where taxonomy terms
 can be edit locked as a proof of concept if anyone is interested. Any
 input appreciated.

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


More information about the wp-trac mailing list