From: Justin Du Date: Tue, 27 Dec 2016 14:36:04 +0000 (-0600) Subject: EditPage: Avoid use of &$this in hooks X-Git-Tag: 1.31.0-rc.0~4455^2 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=074d6ea86f4419899c768f5a2fa0be312f749902;p=lhc%2Fweb%2Fwiklou.git EditPage: Avoid use of &$this in hooks * This triggers warnings in PHP 7.1 Bug: T153505 Change-Id: I5324a6bfe9e8ed255975104c5de7e7a7011cb741 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 1f871e1941..c11df5dc6e 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2602,7 +2602,9 @@ class EditPage { $previewOutput = $this->getPreviewText(); } - Hooks::run( 'EditPage::showEditForm:initial', [ &$this, &$wgOut ] ); + // Avoid PHP 7.1 warning of passing $this by reference + $editPage = $this; + Hooks::run( 'EditPage::showEditForm:initial', [ &$editPage, &$wgOut ] ); $this->setHeaders(); @@ -2679,7 +2681,9 @@ class EditPage { . Xml::closeElement( 'div' ) ); - Hooks::run( 'EditPage::showEditForm:fields', [ &$this, &$wgOut ] ); + // Avoid PHP 7.1 warning of passing $this by reference + $editPage = $this; + Hooks::run( 'EditPage::showEditForm:fields', [ &$editPage, &$wgOut ] ); // Put these up at the top to ensure they aren't lost on early form submission $this->showFormBeforeText(); @@ -3541,7 +3545,9 @@ HTML protected function showConflict() { global $wgOut; - if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$this, &$wgOut ] ) ) { + // Avoid PHP 7.1 warning of passing $this by reference + $editPage = $this; + if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$editPage, &$wgOut ] ) ) { $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); $stats->increment( 'edit.failures.conflict' ); // Only include 'standard' namespaces to avoid creating unknown numbers of statsd metrics @@ -4069,7 +4075,10 @@ HTML $checkboxes['watch'] = $watchThisHtml; } } - Hooks::run( 'EditPageBeforeEditChecks', [ &$this, &$checkboxes, &$tabindex ] ); + + // Avoid PHP 7.1 warning of passing $this by reference + $editPage = $this; + Hooks::run( 'EditPageBeforeEditChecks', [ &$editPage, &$checkboxes, &$tabindex ] ); return $checkboxes; } @@ -4118,7 +4127,9 @@ HTML $buttons['diff'] = Html::submitButton( $this->context->msg( 'showdiff' )->text(), $attribs ); - Hooks::run( 'EditPageBeforeEditButtons', [ &$this, &$buttons, &$tabindex ] ); + // Avoid PHP 7.1 warning of passing $this by reference + $editPage = $this; + Hooks::run( 'EditPageBeforeEditButtons', [ &$editPage, &$buttons, &$tabindex ] ); return $buttons; } @@ -4132,7 +4143,10 @@ HTML $wgOut->prepareErrorPage( $this->context->msg( 'nosuchsectiontitle' ) ); $res = $this->context->msg( 'nosuchsectiontext', $this->section )->parseAsBlock(); - Hooks::run( 'EditPageNoSuchSection', [ &$this, &$res ] ); + + // Avoid PHP 7.1 warning of passing $this by reference + $editPage = $this; + Hooks::run( 'EditPageNoSuchSection', [ &$editPage, &$res ] ); $wgOut->addHTML( $res ); $wgOut->returnToMain( false, $this->mTitle );