From fc684345b11c2daf0d669900bb7ba1fea247b25c Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 7 Oct 2013 14:58:27 -0400 Subject: [PATCH] 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 --- includes/context/DerivativeContext.php | 5 ++++- includes/context/RequestContext.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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; -- 2.20.1