From: withoutaname Date: Sun, 13 Jul 2014 06:41:25 +0000 (-0700) Subject: Make if checks in RequestContext.php more concise X-Git-Tag: 1.31.0-rc.0~14829 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=8c2d4fa8e24fb9f18e3c1f9d5206135b8b5501d1;p=lhc%2Fweb%2Fwiklou.git Make if checks in RequestContext.php more concise Change-Id: Ieb1eaeb595fc77ba926ba6ff96140dff44ba840f --- diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index efdc6db8cc..2c051baa7a 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -154,18 +154,14 @@ class RequestContext implements IContextSource { * @return bool */ public function canUseWikiPage() { - if ( $this->wikipage !== null ) { - # If there's a WikiPage object set, we can for sure get it + if ( $this->wikipage ) { + // If there's a WikiPage object set, we can for sure get it return true; } + // Only pages with legitimate titles can have WikiPages. + // That usually means pages in non-virtual namespaces. $title = $this->getTitle(); - if ( $title === null ) { - # No Title, no WikiPage - return false; - } else { - # Only namespaces whose pages are stored in the database can have WikiPage - return $title->canExist(); - } + return $title ? $title->canExist() : false; } /** @@ -261,7 +257,7 @@ class RequestContext implements IContextSource { $code = strtolower( $code ); # Validate $code - if ( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) { + if ( !$code || !Language::isValidCode( $code ) || $code === 'qqq' ) { wfDebug( "Invalid user language code\n" ); $code = $wgLanguageCode; }