WordPress.org

Make WordPress Core

Changeset 38206


Ignore:
Timestamp:
08/05/2016 07:29:31 PM (5 years ago)
Author:
ocean90
Message:

Update/Install: Replace "error" and "-1" failure messages with a more meaningful one.

  • "-1" is an invalid nonce error, show 'An error has occurred. Please reload the page and try again.'.
  • "error" means that the connection to the server was lost, show 'Connection lost or the server is busy. Please try again later.'.
  • Escape the message in wp-updates-admin-notice because the response may include HTML.
  • Remove HTML tags in wp.updates.isValidResponse() to make PHP's error messages more readable.

Merge of [38205] to the 4.6 branch.

Props azaozz for review.
See #37583.

Location:
branches/4.6
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-admin/includes/update.php

    r38187 r38206  
    632632    ?>
    633633    <script id="tmpl-wp-updates-admin-notice" type="text/html">
    634         <div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{{ data.message }}}</p></div>
     634        <div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{ data.message }}</p></div>
    635635    </script>
    636636    <script id="tmpl-wp-bulk-updates-admin-notice" type="text/html">
  • branches/4.6/src/wp-admin/js/updates.js

    r38200 r38206  
    15631563        }
    15641564
    1565         if ( _.isString( response ) ) {
     1565        if ( _.isString( response ) && '-1' === response ) {
     1566            error = wp.updates.l10n.nonceError;
     1567        } else if ( _.isString( response ) ) {
    15661568            error = response;
     1569        } else if ( 'undefined' !== typeof response.readyState && 0 === response.readyState ) {
     1570            error = wp.updates.l10n.connectionError;
    15671571        } else if ( _.isString( response.responseText ) && '' !== response.responseText ) {
    15681572            error = response.responseText;
     
    15851589        }
    15861590
     1591        // Messages are escaped, remove HTML tags to make them more readable.
     1592        error = error.replace( /<[\/a-z][^<>]*>/gi, '' );
    15871593        errorMessage = errorMessage.replace( '%s', error );
    15881594
  • branches/4.6/src/wp-includes/script-loader.php

    r38204 r38206  
    678678                'activateImporterLabel'      => __( 'Run %s' ),
    679679                'unknownError'               => __( 'An unknown error occurred' ),
     680                'connectionError'            => __( 'Connection lost or the server is busy. Please try again later.' ),
     681                'nonceError'                 => __( 'An error has occurred. Please reload the page and try again.' ),
    680682                'pluginsFound'               => __( 'Number of plugins found: %d' ),
    681683                'noPluginsFound'             => __( 'No plugins found. Try a different search.' ),
  • branches/4.6/tests/qunit/fixtures/updates.js

    r38119 r38206  
    4747        'activateImporter': 'Run Importer',
    4848        'unknownError': 'An unknown error occurred',
     49        'connectionError': 'Connection lost or the server is busy. Please try again later.',
     50        'nonceError': 'An error has occurred. Please reload the page and try again.',
    4951        'pluginsFound': 'Number of plugins found: %d',
    5052        'noPluginsFound': 'No plugins found. Try a different search.'
Note: See TracChangeset for help on using the changeset viewer.