Avoid [GlobalTitleFail] spam
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 26 Sep 2014 17:18:43 +0000 (19:18 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 26 Sep 2014 17:58:02 +0000 (19:58 +0200)
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
includes/context/RequestContext.php

index 545a46f..87468bd 100644 (file)
@@ -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();
index 952af8c..b1bebe7 100644 (file)
@@ -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()