Follow-up r79880: check if $wgLang can be used.
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 9 Jan 2011 17:08:40 +0000 (17:08 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 9 Jan 2011 17:08:40 +0000 (17:08 +0000)
Changed the checks in Database.php to use is_object because of stub objects

includes/Exception.php
includes/db/Database.php

index 76cd641..cd209ab 100644 (file)
@@ -238,14 +238,24 @@ class MWException extends Exception {
 
                $title = Html::element( 'title', null, $this->getPageTitle() );
 
-               $left = $wgLang->alignStart();
-               $right = $wgLang->alignEnd();
+               $left = 'left';
+               $right = 'right';
+               $dir = 'ltr';
+               $code = 'en';
+
+               if ( $this->useMessageCache() ) {
+                       $left = $wgLang->alignStart();
+                       $right = $wgLang->alignEnd();
+                       $dir = $wgLang->getDir();
+                       $code = $wgLang->getCode();
+               }
+
                $header = Html::element( 'img', array(
                        'src' => $wgLogo,
                        'style' => "float: $left; margin-$right: 1em;",
                        'alt' => '' ), $this->getPageTitle() );
 
-               $attribs = array( 'dir' => $wgLang->getDir(), 'lang' => $wgLang->getCode() );
+               $attribs = array( 'dir' => $dir, 'lang' => $code );
 
                return
                        Html::htmlHeader( $attribs ) .
index 4d75379..f2bce43 100644 (file)
@@ -2845,7 +2845,7 @@ class DBConnectionError extends DBError {
 
                $header = "$wgSitename has a problem";
 
-               if ( $wgLang instanceof Language ) {
+               if ( is_object( $wgLang ) ) {
                        $header = htmlspecialchars( $wgLang->getMessage( 'dberr-header' ) );
                }
 
@@ -2859,7 +2859,7 @@ class DBConnectionError extends DBError {
                $again = 'Try waiting a few minutes and reloading.';
                $info  = '(Can\'t contact the database server: $1)';
 
-               if ( $wgLang instanceof Language ) {
+               if ( is_object( $wgLang ) ) {
                        $sorry = htmlspecialchars( $wgLang->getMessage( 'dberr-problems' ) );
                        $again = htmlspecialchars( $wgLang->getMessage( 'dberr-again' ) );
                        $info  = htmlspecialchars( $wgLang->getMessage( 'dberr-info' ) );
@@ -2896,7 +2896,7 @@ class DBConnectionError extends DBError {
                                        $cachederror = "This is a cached copy of the requested page, and may not be up to date. ";
 
                                        # Localize it if possible...
-                                       if ( $wgLang instanceof Language ) {
+                                       if ( is_object( $wgLang ) ) {
                                                $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
                                        }
 
@@ -2921,7 +2921,7 @@ class DBConnectionError extends DBError {
                $outofdate = "Note that their indexes of our content may be out of date.";
                $googlesearch = "Search";
 
-               if ( $wgLang instanceof Language ) {
+               if ( is_object( $wgLang ) ) {
                        $usegoogle = htmlspecialchars( $wgLang->getMessage( 'dberr-usegoogle' ) );
                        $outofdate = htmlspecialchars( $wgLang->getMessage( 'dberr-outofdate' ) );
                        $googlesearch  = htmlspecialchars( $wgLang->getMessage( 'searchbutton' ) );
@@ -2963,7 +2963,7 @@ EOT;
 
                $mainpage = 'Main Page';
 
-               if ( $wgLang instanceof Language ) {
+               if ( is_object( $wgLang ) ) {
                        $mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) );
                }