jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/328387 )

Change subject: upload: Avoid &$this in hooks
......................................................................


upload: Avoid &$this in hooks

&$this triggers warnings in PHP 7.1. Simply renaming the variable before
passing it by reference avoids the warning, without breaking backwards
compatibility.

Bug: T153505
Change-Id: I78ea04a01ecce82294837e92c2a05b00ffb6e0f6
---
M includes/specials/SpecialUpload.php
M includes/upload/UploadBase.php
2 files changed, 12 insertions(+), 5 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/specials/SpecialUpload.php 
b/includes/specials/SpecialUpload.php
index f7e46cb..aabd450 100644
--- a/includes/specials/SpecialUpload.php
+++ b/includes/specials/SpecialUpload.php
@@ -209,7 +209,9 @@
                        $this->processUpload();
                } else {
                        # Backwards compatibility hook
-                       if ( !Hooks::run( 'UploadForm:initial', [ &$this ] ) ) {
+                       // Avoid PHP 7.1 warning of passing $this by reference
+                       $upload = $this;
+                       if ( !Hooks::run( 'UploadForm:initial', [ &$upload ] ) 
) {
                                wfDebug( "Hook 'UploadForm:initial' broke 
output of the upload form\n" );
 
                                return;
@@ -483,8 +485,9 @@
 
                        return;
                }
-
-               if ( !Hooks::run( 'UploadForm:BeforeProcessing', [ &$this ] ) ) 
{
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $upload = $this;
+               if ( !Hooks::run( 'UploadForm:BeforeProcessing', [ &$upload ] ) 
) {
                        wfDebug( "Hook 'UploadForm:BeforeProcessing' broke 
processing the file.\n" );
                        // This code path is deprecated. If you want to break 
upload processing
                        // do so by hooking into the appropriate hooks in 
UploadBase::verifyUpload
@@ -570,7 +573,9 @@
 
                // Success, redirect to description page
                $this->mUploadSuccessful = true;
-               Hooks::run( 'SpecialUploadComplete', [ &$this ] );
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $upload = $this;
+               Hooks::run( 'SpecialUploadComplete', [ &$upload ] );
                $this->getOutput()->redirect( 
$this->mLocalFile->getTitle()->getFullURL() );
        }
 
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index ea6ef30..96f8638 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -775,7 +775,9 @@
                                        User::IGNORE_USER_RIGHTS
                                );
                        }
-                       Hooks::run( 'UploadComplete', [ &$this ] );
+                       // Avoid PHP 7.1 warning of passing $this by reference
+                       $uploadBase = $this;
+                       Hooks::run( 'UploadComplete', [ &$uploadBase ] );
 
                        $this->postProcessUpload();
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/328387
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I78ea04a01ecce82294837e92c2a05b00ffb6e0f6
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Filip <r...@protonmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Filip <r...@protonmail.com>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to