From 9636d44448296b0aceb9f712adc5de3cd38a1dc0 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 24 Jun 2014 15:55:39 +0200 Subject: [PATCH] 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 --- includes/context/RequestContext.php | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) 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; -- 2.20.1