Weaken the recursion guard on RequestContext::getLanguage()
authorTim Starling <tstarling@wikimedia.org>
Fri, 8 Feb 2013 05:38:41 +0000 (16:38 +1100)
committerTim Starling <tstarling@wikimedia.org>
Fri, 8 Feb 2013 05:38:41 +0000 (16:38 +1100)
Just log and soldier on, since for some reason we are seeing a lot of
these exceptions at the moment, with multiple root causes. Based on Matt
Walker's I49dbc2d7. Updates Idc11b547. See bug 44754.

Change-Id: I2e8c062741c1b2ec2acd68dc76d3fb6efb113571

includes/context/RequestContext.php

index 96d27b0..09cb409 100644 (file)
@@ -278,10 +278,14 @@ class RequestContext implements IContextSource {
         */
        public function getLanguage() {
                if ( isset( $this->recursion ) ) {
-                       throw new MWException( 'Recursion detected' );
-               }
-
-               if ( $this->lang === null ) {
+                       trigger_error( "Recursion detected in " . __METHOD__, E_USER_WARNING );
+                       $e = new Exception;
+                       wfDebugLog( 'recursion-guard', "Recursion detected:\n" . $e->getTraceAsString() );
+
+                       global $wgLanguageCode;
+                       $code = ( $wgLanguageCode ) ? $wgLanguageCode : 'en';
+                       $this->lang = Language::factory( $code );
+               } elseif ( $this->lang === null ) {
                        $this->recursion = true;
 
                        global $wgLanguageCode, $wgContLang;