Allow $context->setTitle( null )
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 7 Oct 2013 18:58:27 +0000 (14:58 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 7 Oct 2013 19:01:01 +0000 (15:01 -0400)
If something is messing around with $wgTitle before MediaWiki::main()
sets $wgTitle in the first place, it needs to be able to reset it back
to null to avoid a problem like bug 53498. And to do that properly, it
also needs to be able to clear the title in the RequestContext.

Bug: 55435
Change-Id: I6c763b70bbffa0762ca52e61acf7dc200da4075f

includes/context/DerivativeContext.php
includes/context/RequestContext.php

index d4caf05..fd9bf96 100644 (file)
@@ -100,7 +100,10 @@ class DerivativeContext extends ContextSource {
         *
         * @param Title $t
         */
-       public function setTitle( Title $t ) {
+       public function setTitle( $t ) {
+               if ( $t !== null && !$t instanceof Title ) {
+                       throw new MWException( __METHOD__ . " expects an instance of Title" );
+               }
                $this->title = $t;
        }
 
index b9dbe77..01ec57c 100644 (file)
@@ -90,7 +90,10 @@ class RequestContext implements IContextSource {
         *
         * @param Title $t
         */
-       public function setTitle( Title $t ) {
+       public function setTitle( $t ) {
+               if ( $t !== null && !$t instanceof Title ) {
+                       throw new MWException( __METHOD__ . " expects an instance of Title" );
+               }
                $this->title = $t;
                // Erase the WikiPage so a new one with the new title gets created.
                $this->wikipage = null;