From: umherirrender Date: Fri, 26 Sep 2014 17:18:43 +0000 (+0200) Subject: Avoid [GlobalTitleFail] spam X-Git-Tag: 1.31.0-rc.0~13805^2 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=010cdb436008df7ef35198eb21981abd54c0df98;p=lhc%2Fweb%2Fwiklou.git Avoid [GlobalTitleFail] spam MediaWiki::getTitle is checking, if a title is set on the context, but that needs to call RequestContext::getTitle, which gives a warning, when no title is set: RequestContext::getTitle called by MediaWiki::getTitle with no title set. Adding a RequestContext::hasTitle function to check the title and avoid the warning. Was added in I72c5c3fb75c9ceff02390c91b3735f2da90845de. Change-Id: I4d8f8ef799cd91f0d2affe881019583ac77a31b7 --- diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 545a46f63c..87468bd2bf 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -121,7 +121,7 @@ class MediaWiki { * @return Title */ public function getTitle() { - if ( $this->context->getTitle() === null ) { + if ( !$this->context->hasTitle() ) { $this->context->setTitle( $this->parseTitle() ); } return $this->context->getTitle(); diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index 952af8cdeb..b1bebe7c2b 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -146,6 +146,16 @@ class RequestContext implements IContextSource { return $this->title; } + /** + * Check, if a Title object is set + * + * @since 1.25 + * @return bool + */ + public function hasTitle() { + return $this->title !== null; + } + /** * Check whether a WikiPage object can be get with getWikiPage(). * Callers should expect that an exception is thrown from getWikiPage()