EditPage: Try to avoid using $wgTitle
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 20 Sep 2017 04:30:21 +0000 (21:30 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 20 Sep 2017 04:30:21 +0000 (21:30 -0700)
The most common code path is from EditAction, so make sure
EditPage::setContextTitle() is called in that case.

Log any uses that fallback to $wgTitle in the GlobalTitleFail log group.

Bug: T144366
Change-Id: Ie6c7dfbaa432239389d210051372427b8fa045b4

includes/EditPage.php
includes/actions/EditAction.php

index 6bcf293..7750b10 100644 (file)
@@ -469,6 +469,10 @@ class EditPage {
         */
        public function getContextTitle() {
                if ( is_null( $this->mContextTitle ) ) {
         */
        public function getContextTitle() {
                if ( is_null( $this->mContextTitle ) ) {
+                       wfDebugLog(
+                               'GlobalTitleFail',
+                               __METHOD__ . ' called by ' . wfGetAllCallers( 5 ) . ' with no title set.'
+                       );
                        global $wgTitle;
                        return $wgTitle;
                } else {
                        global $wgTitle;
                        return $wgTitle;
                } else {
index acfd72e..f0bc8bf 100644 (file)
@@ -56,6 +56,7 @@ class EditAction extends FormlessAction {
 
                if ( Hooks::run( 'CustomEditor', [ $page, $user ] ) ) {
                        $editor = new EditPage( $page );
 
                if ( Hooks::run( 'CustomEditor', [ $page, $user ] ) ) {
                        $editor = new EditPage( $page );
+                       $editor->setContextTitle( $this->getTitle() );
                        $editor->edit();
                }
        }
                        $editor->edit();
                }
        }