Make WordPress Core

Changeset 25874


Ignore:
Timestamp:
10/22/2013 09:26:04 PM (12 years ago)
Author:
nacin
Message:

Have heartbeat's connection lost notice handle 503 errors send by the upgrader's maintenance mode.

fixes #25660 for 3.7.

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/autosave.js

    r24849 r25874  
    142142
    143143    // When connection is lost, keep user from submitting changes.
    144     $(document).on('heartbeat-connection-lost.autosave', function( e, error ) {
    145         if ( 'timeout' === error ) {
     144    $(document).on('heartbeat-connection-lost.autosave', function( e, error, status ) {
     145        if ( 'timeout' === error || 503 == status ) {
    146146            var notice = $('#lost-connection-notice');
    147147            if ( ! wp.autosave.local.hasStorage ) {
  • trunk/src/wp-includes/js/heartbeat.js

    r25078 r25874  
    4646            winBlurTimeout,
    4747            frameBlurTimeout = -1,
    48             hasConnectionError = false;
     48            hasConnectionError = null;
    4949
    5050        /**
     
    5454         */
    5555        this.hasConnectionError = function() {
    56             return hasConnectionError;
     56            return !! hasConnectionError;
    5757        };
    5858
     
    109109
    110110        // Set error state and fire an event on XHR errors or timeout
    111         function errorstate( error ) {
     111        function errorstate( error, status ) {
    112112            var trigger;
    113113
     
    133133                }
    134134
     135                if ( 503 == status && false === hasConnectionError ) {
     136                    trigger = true;
     137                }
     138
    135139                if ( trigger && ! self.hasConnectionError() ) {
    136140                    hasConnectionError = true;
    137                     $(document).trigger( 'heartbeat-connection-lost', [error] );
     141                    $(document).trigger( 'heartbeat-connection-lost', [error, status] );
    138142                }
    139143            } else if ( self.hasConnectionError() ) {
     
    141145                hasConnectionError = false;
    142146                $(document).trigger( 'heartbeat-connection-restored' );
     147            } else if ( null === hasConnectionError ) {
     148                hasConnectionError = false;
    143149            }
    144150        }
     
    214220                next();
    215221            }).fail( function( jqXHR, textStatus, error ) {
    216                 errorstate( textStatus || 'unknown' );
     222                errorstate( textStatus || 'unknown', jqXHR.status );
    217223                self.error( jqXHR, textStatus, error );
    218224            });
Note: See TracChangeset for help on using the changeset viewer.