From: Niklas Laxström
Date: Sat, 31 Jan 2009 19:49:41 +0000 (+0000)
Subject: * Cleanup database error message code
X-Git-Tag: 1.31.0-rc.0~43095
X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=4f4501c24f6e2432cbb604e824b44606a2b1e958;p=lhc%2Fweb%2Fwiklou.git
* Cleanup database error message code
* (bug 7480) Internationalize database error message
---
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 0f4c86b5ec..77835019f4 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -124,6 +124,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
results for category names that include pseudo-namespaces
* (bug 17252) Galician numbering format
* (bug 17146) Fix for UTF-8 and short word search for some possible MySQL configs
+* (bug 7480) Internationalize database error message
== API changes in 1.15 ==
* (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
diff --git a/includes/db/Database.php b/includes/db/Database.php
index 798dc7d369..82db7da07b 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -2518,44 +2518,27 @@ class DBConnectionError extends DBError {
}
function getPageTitle() {
- global $wgSitename;
- return "$wgSitename has a problem";
+ global $wgSitename, $wgLang;
+ $header = "$wgSitename has a problem";
+ if ( $wgLang instanceof Language ) {
+ $header = htmlspecialchars( $wgLang->getMessage( 'dberr-header' ) );
+ }
+
+ return $header;
}
function getHTML() {
- global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding;
- global $wgSitename, $wgServer, $wgMessageCache;
-
- # I give up, Brion is right. Getting the message cache to work when there is no DB is tricky.
- # Hard coding strings instead.
+ global $wgLang, $wgMessageCache, $wgUseFileCache;
- $noconnect = "Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.
(Can't contact the database server: $1)
";
- $mainpage = 'Main Page';
- $searchdisabled = <<$wgSitename search is disabled for performance reasons. You can search via Google in the meantime.
-Note that their indexes of $wgSitename content may be out of date.
',
-EOT;
+ $sorry = 'Sorry! This site is experiencing technical difficulties.';
+ $again = 'Try waiting a few minutes and reloading.';
+ $info = '(Can\'t contact the database server: $1)';
- $googlesearch = "
-
-
-";
- $cachederror = "The following is a cached copy of the requested page, and may not be up to date. ";
+ if ( $wgLang instanceof Language ) {
+ $sorry = htmlspecialchars( $wgLang->getMessage( 'dberr-problems' ) );
+ $again = htmlspecialchars( $wgLang->getMessage( 'dberr-again' ) );
+ $info = htmlspecialchars( $wgLang->getMessage( 'dberr-info' ) );
+ }
# No database access
if ( is_object( $wgMessageCache ) ) {
@@ -2566,6 +2549,7 @@ border=\"0\" ALT=\"Google\">
$this->error = $this->db->getProperty('mServer');
}
+ $noconnect = "$sorry
$again
$info
";
$text = str_replace( '$1', $this->error, $noconnect );
/*
@@ -2575,38 +2559,81 @@ border=\"0\" ALT=\"Google\">
"\n";
}*/
+ $extra = $this->searchForm();
+
if($wgUseFileCache) {
- if($wgTitle) {
- $t =& $wgTitle;
- } else {
- if($title) {
- $t = Title::newFromURL( $title );
- } elseif (@/**/$_REQUEST['search']) {
- $search = $_REQUEST['search'];
- return $searchdisabled .
- str_replace( array( '$1', '$2' ), array( htmlspecialchars( $search ),
- $wgInputEncoding ), $googlesearch );
- } else {
- $t = Title::newFromText( $mainpage );
- }
- }
+ $cache = $this->fileCachedPage();
+ if ( $cache !== null ) $extra = $cache;
+ }
- $cache = new HTMLFileCache( $t );
- if( $cache->isFileCached() ) {
- // @todo, FIXME: $msg is not defined on the next line.
- $msg = ''.$text."
\n" .
- $cachederror . "
\n";
-
- $tag = '';
- $text = str_replace(
- $tag,
- $tag . $text,
- $cache->fetchPageText() );
- }
+ return $text . '
' . $extra;
+ }
+
+ function searchForm() {
+ global $wgSitename, $wgServer, $wgLang, $wgInputEncoding;
+ $usegoogle = "You can try searching via Google in the meantime.";
+ $outofdate = "Note that their indexes of our content may be out of date.";
+ $googlesearch = "Search";
+
+ if ( $wgLang instanceof Language ) {
+ $usegoogle = htmlspecialchars( $wgLang->getMessage( 'dberr-usegoogle' ) );
+ $outofdate = htmlspecialchars( $wgLang->getMessage( 'dberr-outofdate' ) );
+ $googlesearch = htmlspecialchars( $wgLang->getMessage( 'searchbutton' ) );
}
- return $text;
+ $search = htmlspecialchars(@$_REQUEST['search']);
+
+ $trygoogle = <<$usegoogle
+$outofdate
+
+
+
+EOT;
+ return $trygoogle;
}
+
+ function fileCachedPage() {
+ global $wgTitle, $title, $wgLang;
+
+ $cachederror = "The following is a cached copy of the requested page, and may not be up to date. ";
+ $mainpage = 'Main Page';
+ if ( $wgLang instanceof Language ) {
+ $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
+ $mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) );
+ }
+
+ if($wgTitle) {
+ $t =& $wgTitle;
+ } elseif($title) {
+ $t = Title::newFromURL( $title );
+ } else {
+ $t = Title::newFromText( $mainpage );
+ }
+
+ $cache = new HTMLFileCache( $t );
+ if( $cache->isFileCached() ) {
+ $warning = "$cachederror
";
+ return $warning . $cache->fetchPageText();
+ } else {
+ return '';
+ }
+ }
+
}
/**
diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php
index dfa766806a..9a58957adf 100644
--- a/languages/messages/MessagesEn.php
+++ b/languages/messages/MessagesEn.php
@@ -3815,4 +3815,13 @@ Enter the filename without the "{{ns:file}}:" prefix.',
'tags-edit' => 'edit',
'tags-hitcount' => '$1 {{PLURAL:$1|change|changes}}',
+# Hardcoded dberror messages
+'dberr-header' => 'This wiki has a problem',
+'dberr-problems' => 'Sorry! This site is experiencing technical difficulties.',
+'dberr-again' => 'Try waiting a few minutes and reloading.',
+'dberr-info' => '(Can\'t contact the database server: $1)',
+
+'dberr-usegoogle' => 'You can try searching via Google in the meantime.',
+'dberr-outofdate' => 'Note that their indexes of our content may be out of date.',
+'dberr-cachederror' => 'The following is a cached copy of the requested page, and may not be up to date.',
);
diff --git a/languages/messages/MessagesFi.php b/languages/messages/MessagesFi.php
index 0637f7be2e..66c9a1b66c 100644
--- a/languages/messages/MessagesFi.php
+++ b/languages/messages/MessagesFi.php
@@ -2910,4 +2910,13 @@ Kirjoita tiedostonimi ilman â{{ns:file}}:â-etuliitettä.',
'tags-edit' => 'muokkaa',
'tags-hitcount' => '$1 {{PLURAL:$1|muutos|muutosta}}',
+'dberr-header' => 'Wikissä on tietokantaongelma',
+'dberr-problems' => 'Tällä sivustolla on teknisiä ongelmia.',
+'dberr-again' => 'Odota hetki ja lataa sivu uudelleen.',
+'dberr-info' => '(Tietokantapalvelimeen yhdistäminen epäonnistui: $1)',
+
+'dberr-usegoogle' => 'Voit koittaa etsiä Googlesta kunnes virhe korjataan.',
+'dberr-outofdate' => 'Googlen indeksi ei välttämättä ole ajan tasalla.',
+'dberr-cachederror' => 'Alla on välimuistissa oleva sivun version, joka ei välttämättä ole ajan tasalla.',
+
);