Make WordPress Core

Ticket #25660: 25660.3.diff

File 25660.3.diff, 2.4 KB (added by azaozz, 12 years ago)
  • src/wp-includes/js/autosave.js

     
    141141        }
    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 ) {
    148148                                notice.find('.hide-if-no-sessionstorage').hide();
  • src/wp-includes/js/heartbeat.js

     
    4545                        userActiveEvents,
    4646                        winBlurTimeout,
    4747                        frameBlurTimeout = -1,
    48                         hasConnectionError = false;
     48                        hasConnectionError = null;
    4949
    5050                /**
    5151                 * Returns a boolean that's indicative of whether or not there is a connection error
     
    5353                 * @returns boolean
    5454                 */
    5555                this.hasConnectionError = function() {
    56                         return hasConnectionError;
     56                        return !! hasConnectionError;
    5757                };
    5858
    5959                if ( typeof( window.heartbeatSettings ) == 'object' ) {
     
    108108                }
    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
    114114                        if ( error ) {
     
    132132                                                break;
    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() ) {
    140144                                errorcount = 0;
    141145                                hasConnectionError = false;
    142146                                $(document).trigger( 'heartbeat-connection-restored' );
     147                        } else if ( null === hasConnectionError ) {
     148                                hasConnectionError = false;
    143149                        }
    144150                }
    145151
     
    213219                                connecting = false;
    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                        });
    219225                }