From: daniel Date: Tue, 24 Jun 2014 13:55:39 +0000 (+0200) Subject: Guard recursion flag against exceptions. X-Git-Tag: 1.31.0-rc.0~15267 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=9636d44448296b0aceb9f712adc5de3cd38a1dc0;p=lhc%2Fweb%2Fwiklou.git Guard recursion flag against exceptions. To avoid misleading errors in case of failed initialization, flags used to protected against recursion need to be reset in case of an exception being thrown. Change-Id: Ifbc1db4b827012177fcfd271981179ebb2329b52 --- diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index cb137fe0f9..93602a0d77 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -308,22 +308,28 @@ class RequestContext implements IContextSource { global $wgLanguageCode, $wgContLang; - $request = $this->getRequest(); - $user = $this->getUser(); + try { + $request = $this->getRequest(); + $user = $this->getUser(); - $code = $request->getVal( 'uselang', $user->getOption( 'language' ) ); - $code = self::sanitizeLangCode( $code ); + $code = $request->getVal( 'uselang', $user->getOption( 'language' ) ); + $code = self::sanitizeLangCode( $code ); - wfRunHooks( 'UserGetLanguageObject', array( $user, &$code, $this ) ); + wfRunHooks( 'UserGetLanguageObject', array( $user, &$code, $this ) ); - if ( $code === $wgLanguageCode ) { - $this->lang = $wgContLang; - } else { - $obj = Language::factory( $code ); - $this->lang = $obj; - } + if ( $code === $wgLanguageCode ) { + $this->lang = $wgContLang; + } else { + $obj = Language::factory( $code ); + $this->lang = $obj; + } - unset( $this->recursion ); + unset( $this->recursion ); + } + catch ( Exception $ex ) { + unset( $this->recursion ); + throw $ex; + } } return $this->lang;