Check hasTitle() in RequestContext::setWikiPage()
authorKunal Mehta <legoktm@gmail.com>
Fri, 12 Dec 2014 19:17:55 +0000 (11:17 -0800)
committerKunal Mehta <legoktm@gmail.com>
Fri, 12 Dec 2014 19:41:22 +0000 (11:41 -0800)
Calling getTitle() right away can lead to reading from
$wgTitle, so check with hasTitle() first.

This avoids a globaltitlefail in ApiEditPage.

Change-Id: I749cc33dd4f1fd6bc7598be34f37e591d822c3f2

includes/context/RequestContext.php

index fe17fde..c76e3a9 100644 (file)
@@ -182,9 +182,8 @@ class RequestContext implements IContextSource {
         * @param WikiPage $p
         */
        public function setWikiPage( WikiPage $p ) {
-               $contextTitle = $this->getTitle();
                $pageTitle = $p->getTitle();
-               if ( !$contextTitle || !$pageTitle->equals( $contextTitle ) ) {
+               if ( !$this->hasTitle() || !$pageTitle->equals( $this->getTitle() ) ) {
                        $this->setTitle( $pageTitle );
                }
                // Defer this to the end since setTitle sets it to null.