From 50e6ef8bd7b490f36020a9b936469d449c281410 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 8 Oct 2015 16:52:24 +0000 Subject: [PATCH] Split database error messages into separate strings to remove unnecessary HTML tags from translations. Add translator comments for placeholders. Fixes #34216. Built from https://develop.svn.wordpress.org/trunk@34942 git-svn-id: http://core.svn.wordpress.org/trunk@34907 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 103 +++++++++++++++++++++++++++++----------- 2 files changed, 77 insertions(+), 28 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 0883f0c050..061f1f126c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34941'; +$wp_version = '4.4-alpha-34942'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 008550d2a5..8e6c053d38 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1052,14 +1052,40 @@ class wpdb { $this->ready = false; if ( ! did_action( 'template_redirect' ) ) { wp_load_translations_early(); - $this->bail( sprintf( __( '

Can’t select database

-

We were able to connect to the database server (which means your username and password is okay) but not able to select the %1$s database.

- -

If you don\'t know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.

' ), htmlspecialchars( $db, ENT_QUOTES ), htmlspecialchars( $this->dbuser, ENT_QUOTES ) ), 'db_select_fail' ); + + $message = '

' . __( 'Can’t select database' ) . "

\n"; + + $message .= '

' . sprintf( + /* translators: %s: database name */ + __( 'We were able to connect to the database server (which means your username and password is okay) but not able to select the %s database.' ), + '' . htmlspecialchars( $db, ENT_QUOTES ) . '' + ) . "

\n"; + + $message .= "\n"; + + $message .= '

' . sprintf( + /* translators: %s: support forums URL */ + __( 'If you don’t know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.' ), + __( 'https://wordpress.org/support/' ) + ) . "

\n"; + + $this->bail( $message, 'db_select_fail' ); } } } @@ -1503,16 +1529,28 @@ class wpdb { die(); } - $this->bail( sprintf( __( " -

Error establishing a database connection

-

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at %s. This could mean your host's database server is down.

- -

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

-" ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' ); + $message = '

' . __( 'Error establishing a database connection' ) . "

\n"; + + $message .= '

' . sprintf( + /* translators: 1: wp-config.php. 2: database host */ + __( 'This either means that the username and password information in your %1$s file is incorrect or we can’t contact the database server at %2$s. This could mean your host’s database server is down.' ), + 'wp-config.php', + '' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '' + ) . "

\n"; + + $message .= "\n"; + + $message .= '

' . sprintf( + /* translators: %s: support forums URL */ + __( 'If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.' ), + __( 'https://wordpress.org/support/' ) + ) . "

\n"; + + $this->bail( $message, 'db_connect_fail' ); return false; } elseif ( $this->dbh ) { @@ -1595,16 +1633,27 @@ class wpdb { return false; } + $message = '

' . __( 'Error reconnecting to the database' ) . "

\n"; + + $message .= '

' . sprintf( + /* translators: %s: database host */ + __( 'This means that we lost contact with the database server at %s. This could mean your host’s database server is down.' ), + '' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '' + ) . "

\n"; + + $message .= "\n"; + + $message .= '

' . sprintf( + /* translators: %s: support forums URL */ + __( 'If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.' ), + __( 'https://wordpress.org/support/' ) + ) . "

\n"; + // We weren't able to reconnect, so we better bail. - $this->bail( sprintf( ( " -

Error reconnecting to the database

-

This means that we lost contact with the database server at %s. This could mean your host's database server is down.

- -

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

-" ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' ); + $this->bail( $message, 'db_connect_fail' ); // Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily). dead_db();