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.
Built from https://develop.svn.wordpress.org/branches/4.6@38206


git-svn-id: http://core.svn.wordpress.org/branches/4.6@38147 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-08-05 19:30:31 +00:00
parent 0a65e04101
commit b5de2df420
5 changed files with 13 additions and 5 deletions

View File

@ -631,7 +631,7 @@ function maintenance_nag() {
function wp_print_admin_notice_templates() {
?>
<script id="tmpl-wp-updates-admin-notice" type="text/html">
<div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{{ data.message }}}</p></div>
<div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{ data.message }}</p></div>
</script>
<script id="tmpl-wp-bulk-updates-admin-notice" type="text/html">
<div id="{{ data.id }}" class="{{ data.className }} notice <# if ( data.errors ) { #>notice-error<# } else { #>notice-success<# } #>">

View File

@ -1562,8 +1562,12 @@
return true;
}
if ( _.isString( response ) ) {
if ( _.isString( response ) && '-1' === response ) {
error = wp.updates.l10n.nonceError;
} else if ( _.isString( response ) ) {
error = response;
} else if ( 'undefined' !== typeof response.readyState && 0 === response.readyState ) {
error = wp.updates.l10n.connectionError;
} else if ( _.isString( response.responseText ) && '' !== response.responseText ) {
error = response.responseText;
} else if ( _.isString( response.statusText ) ) {
@ -1584,6 +1588,8 @@
break;
}
// Messages are escaped, remove HTML tags to make them more readable.
error = error.replace( /<[\/a-z][^<>]*>/gi, '' );
errorMessage = errorMessage.replace( '%s', error );
// Add admin notice.

File diff suppressed because one or more lines are too long

View File

@ -677,6 +677,8 @@ function wp_default_scripts( &$scripts ) {
/* translators: %s: Importer name */
'activateImporterLabel' => __( 'Run %s' ),
'unknownError' => __( 'An unknown error occurred' ),
'connectionError' => __( 'Connection lost or the server is busy. Please try again later.' ),
'nonceError' => __( 'An error has occurred. Please reload the page and try again.' ),
'pluginsFound' => __( 'Number of plugins found: %d' ),
'noPluginsFound' => __( 'No plugins found. Try a different search.' ),
),

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-RC1-38204';
$wp_version = '4.6-RC1-38206';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.