From: Brad Jorsch Date: Mon, 7 Oct 2013 18:58:27 +0000 (-0400) Subject: Allow $context->setTitle( null ) X-Git-Tag: 1.31.0-rc.0~18571^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=fc684345b11c2daf0d669900bb7ba1fea247b25c;p=lhc%2Fweb%2Fwiklou.git Allow $context->setTitle( null ) 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 --- diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index d4caf05dab..fd9bf96338 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -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; } diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index b9dbe77e16..01ec57c086 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -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;