From 3742d1058dfc93fc8b4099ebcbc94a4926af7551 Mon Sep 17 00:00:00 2001 From: Alex Z Date: Thu, 16 Jul 2009 15:18:57 +0000 Subject: [PATCH] (bug 19590) Database error messages are no longer hardcoded to use "MySQL". Added a new function DatabaseBase::getDBtype() to get the DB type for messages, updated all subclasses. Message change needs propagating. --- RELEASE-NOTES | 2 ++ includes/db/Database.php | 17 +++++++++++++++-- includes/db/DatabaseIbm_db2.php | 7 +++++++ includes/db/DatabaseMssql.php | 7 +++++++ includes/db/DatabaseMysql.php | 7 +++++++ includes/db/DatabaseOracle.php | 7 +++++++ includes/db/DatabasePostgres.php | 7 +++++++ includes/db/DatabaseSqlite.php | 7 +++++++ languages/messages/MessagesEn.php | 4 ++-- 9 files changed, 61 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1b65c01542..703de6d269 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -276,6 +276,8 @@ this. Was used when mwEmbed was going to be an extension. * (bug 19513) RTL fixes for new Search UI * (bug 16497) Special:Allmessages is paginated * (bug 18708) CSS plainlinks class now available to all skins +* (bug 19590) Database error messages no longer have "MySQL" hardcoded as the + database type == API changes in 1.16 == diff --git a/includes/db/Database.php b/includes/db/Database.php index 25a340c2f7..ac4fd696e0 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1952,6 +1952,17 @@ abstract class DatabaseBase { return '(no software link given)'; } + /** + * Returns the database type for user-visible purposes + * e.g. DB error messages + * Other uses should just use $wgDBtype + * + * @return String: Database name for messages + */ + function getDBtype() { + return 'Database'; + } + /** * A string describing the current software version, like from * mysql_get_server_info(). Will be listed on Special:Version, etc. @@ -2548,7 +2559,8 @@ class DBQueryError extends DBError { function getText() { if ( $this->useMessageCache() ) { return wfMsg( 'dberrortextcl', htmlspecialchars( $this->getSQL() ), - htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ) ) . "\n"; + htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ), + htmlspecialchars( $this->db->getDBtype() ) ) . "\n"; } else { return $this->getMessage(); } @@ -2575,7 +2587,8 @@ class DBQueryError extends DBError { function getHTML() { if ( $this->useMessageCache() ) { return wfMsgNoDB( 'dberrortext', htmlspecialchars( $this->getSQL() ), - htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ) ); + htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ), + htmlspecialchars( $this->db->getDBtype() ) ); } else { return nl2br( htmlspecialchars( $this->getMessage() ) ); } diff --git a/includes/db/DatabaseIbm_db2.php b/includes/db/DatabaseIbm_db2.php index f56186089d..c750b28c17 100644 --- a/includes/db/DatabaseIbm_db2.php +++ b/includes/db/DatabaseIbm_db2.php @@ -1453,6 +1453,13 @@ EOF; return "[http://www.ibm.com/software/data/db2/express/?s_cmp=ECDDWW01&s_tact=MediaWiki IBM DB2]"; } + /** + * @return String: Database name for messages + */ + function getDBtype() { + return 'IBM DB2'; + } + ### # Fix search crash ### diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index eef2033d6b..0953088ae7 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -899,6 +899,13 @@ class DatabaseMssql extends DatabaseBase { return "[http://www.microsoft.com/sql/default.mspx Microsoft SQL Server 2005 Home]"; } + /** + * @return String: Database name for messages + */ + function getDBtype() { + return 'Microsoft SQL Server'; + } + /** * @return string Version information from the database */ diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 83a7bc5401..28ca5a3e79 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -289,6 +289,13 @@ class DatabaseMysql extends DatabaseBase { return '[http://www.mysql.com/ MySQL]'; } + /** + * @return String: Database name for messages + */ + function getDBtype() { + return 'MySQL'; + } + public function setTimeout( $timeout ) { $this->query( "SET net_read_timeout=$timeout" ); $this->query( "SET net_write_timeout=$timeout" ); diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 634a68a81b..69d406c2fa 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -742,6 +742,13 @@ class DatabaseOracle extends DatabaseBase { return oci_server_version($this->mConn); } + /** + * @return String: Database name for messages + */ + function getDBtype() { + return 'Oracle'; + } + /** * Query whether a given table exists (in the given schema, or the default mw one if not given) */ diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 25649e426a..09c7bd3b29 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -1047,6 +1047,13 @@ class DatabasePostgres extends DatabaseBase { return "[http://www.postgresql.org/ PostgreSQL]"; } + /** + * @return String: Database name for messages + */ + function getDBtype() { + return 'PostgreSQL'; + } + /** * @return string Version information from the database */ diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index 93b0b44d95..014bef21e7 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -287,6 +287,13 @@ class DatabaseSqlite extends DatabaseBase { return "[http://sqlite.org/ SQLite]"; } + /** + * @return String: Database name for messages + */ + function getDBtype() { + return 'SQLite'; + } + /** * @return string Version information from the database */ diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 984fb795f4..09205760be 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -947,12 +947,12 @@ This may indicate a bug in the software. The last attempted database query was:
$1
from within function "$2". -MySQL returned error "$3: $4".', +$5 returned error "$3: $4".', 'dberrortextcl' => 'A database query syntax error has occurred. The last attempted database query was: "$1" from within function "$2". -MySQL returned error "$3: $4"', +$5 returned error "$3: $4"', 'laggedslavemode' => "'''Warning:''' Page may not contain recent updates.", 'readonly' => 'Database locked', 'enterlockreason' => 'Enter a reason for the lock, including an estimate of when the lock will be released', -- 2.20.1