From: Kunal Mehta Date: Wed, 20 Sep 2017 04:30:21 +0000 (-0700) Subject: EditPage: Try to avoid using $wgTitle X-Git-Tag: 1.31.0-rc.0~2021^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=5cd20435dc1aa512e2033041b09e026c342f8516 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 --- 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(); } }