From 5cd20435dc1aa512e2033041b09e026c342f8516 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 19 Sep 2017 21:30:21 -0700 Subject: [PATCH] EditPage: Try to avoid using $wgTitle 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 | 4 ++++ includes/actions/EditAction.php | 1 + 2 files changed, 5 insertions(+) diff --git a/includes/EditPage.php b/includes/EditPage.php index 6bcf293a34..7750b10acb 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -469,6 +469,10 @@ class EditPage { */ public function getContextTitle() { if ( is_null( $this->mContextTitle ) ) { + wfDebugLog( + 'GlobalTitleFail', + __METHOD__ . ' called by ' . wfGetAllCallers( 5 ) . ' with no title set.' + ); global $wgTitle; return $wgTitle; } else { diff --git a/includes/actions/EditAction.php b/includes/actions/EditAction.php index acfd72e019..f0bc8bff91 100644 --- a/includes/actions/EditAction.php +++ b/includes/actions/EditAction.php @@ -56,6 +56,7 @@ class EditAction extends FormlessAction { if ( Hooks::run( 'CustomEditor', [ $page, $user ] ) ) { $editor = new EditPage( $page ); + $editor->setContextTitle( $this->getTitle() ); $editor->edit(); } } -- 2.20.1