[wp-trac] [WordPress Trac] #31819: Shiny updates: more sophisticated locking

WordPress Trac noreply at wordpress.org
Tue Apr 7 02:24:59 UTC 2015


#31819: Shiny updates: more sophisticated locking
-------------------------------------+-------------------------------------
 Reporter:  DavidAnderson            |       Owner:  jorbin
     Type:  enhancement              |      Status:  assigned
 Priority:  normal                   |   Milestone:  4.2
Component:  Upgrade/Install          |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  shiny-updates has-patch  |     Focuses:  ui, javascript,
  dev-feedback close                 |  administration
-------------------------------------+-------------------------------------

Comment (by jorbin):

 @DavidAnderson

 Thanks for sharing the file with Helen and Nacin.  I've taken a look and a
 couple of things:

 1) I think adding the events to completion will eliminate your need to do
 polling. I'm going to do that now.

 2) Having the lock in place at the start is going to degrade the
 experience since we have the AYS check. An alternative would be to use the
 jQuery ajax events. For example the code below will detect an attempt at a
 shiny update before it is sent. You can save a copy of the request, abort
 the original, and add the interaction that you need for your plugin.  Then
 on completion of that interaction, restart the original request (you'll
 need to add some logic to ensure this doesn't create an infinite loop. )
 {{{
 getQueryParams = function(queryString) {
     var query = queryString;
     if (!query) {
         return false;
     }
     return _
     .chain(query.split('&'))
     .map(function(params) {
         var p = params.split('=');
         return [p[0], decodeURIComponent(p[1])];
     })
     .object()
     .value();
 };

 jQuery.ajaxSetup( {beforeSend: function(e, data) {
     var requestData = getQueryParams( data.data );

     if ( data.type == "POST" && requestData.action === "update-plugin" ) {
         // store the request you want to make
         // do what you need to do
         e.abort();
     }
 }} );
 }}}

 3) As I mentioned above, as of [31949] the original html of what turns
 into "updating..." is saved.

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


More information about the wp-trac mailing list