From 010cdb436008df7ef35198eb21981abd54c0df98 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 26 Sep 2014 19:18:43 +0200 Subject: [PATCH] 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 --- includes/MediaWiki.php | 2 +- includes/context/RequestContext.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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() -- 2.20.1