[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_27]: Avoid passing $this by reference in hooks

2017-08-27 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/374093 )

Change subject: Avoid passing $this by reference in hooks
..


Avoid passing $this by reference in hooks

Renamed $this passed by reference usages in hooks inside includes directory

Bug: T153505
Change-Id: Ib3e6a288a423958e75b5c1bfe53dc29e0f3fee6d
(cherry picked from commit b98aa152b340b2e77a25c92c413d5950af5f4ca8)
---
M includes/Block.php
M includes/OutputPage.php
M includes/Revision.php
3 files changed, 18 insertions(+), 6 deletions(-)

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



diff --git a/includes/Block.php b/includes/Block.php
index 79b31bb..827099a 100644
--- a/includes/Block.php
+++ b/includes/Block.php
@@ -741,8 +741,10 @@
return false;
}
 
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $block = $this;
# Allow hooks to cancel the autoblock.
-   if ( !Hooks::run( 'AbortAutoblock', [ $autoblockIP, &$this ] ) 
) {
+   if ( !Hooks::run( 'AbortAutoblock', [ $autoblockIP, &$block ] ) 
) {
wfDebug( "Autoblock aborted by hook.\n" );
return false;
}
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index e5be2c7..c04d3b4 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1311,10 +1311,12 @@
}
}
 
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
# Add the remaining categories to the skin
if ( Hooks::run(
'OutputPageMakeCategoryLinks',
-   [ &$this, $categories, &$this->mCategoryLinks ] )
+   [ &$outputPage, $categories, &$this->mCategoryLinks ] )
) {
foreach ( $categories as $category => $type ) {
// array keys will cast numeric category names 
to ints, so cast back to string
@@ -1810,8 +1812,10 @@
// Link flags are ignored for now, but may in the future be
// used to mark individual language links.
$linkFlags = [];
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
Hooks::run( 'LanguageLinks', [ $this->getTitle(), 
&$this->mLanguageLinks, &$linkFlags ] );
-   Hooks::run( 'OutputPageParserOutput', [ &$this, $parserOutput ] 
);
+   Hooks::run( 'OutputPageParserOutput', [ &$outputPage, 
$parserOutput ] );
}
 
/**
@@ -1839,7 +1843,9 @@
 */
public function addParserOutputText( $parserOutput ) {
$text = $parserOutput->getText();
-   Hooks::run( 'OutputPageBeforeHTML', [ &$this, &$text ] );
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
+   Hooks::run( 'OutputPageBeforeHTML', [ &$outputPage, &$text ] );
$this->addHTML( $text );
}
 
@@ -2319,9 +2325,11 @@
}
MWDebug::addModules( $this );
 
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
// Hook that allows last minute changes to the output 
page, e.g.
// adding of CSS or Javascript by extensions.
-   Hooks::run( 'BeforePageDisplay', [ &$this, &$sk ] );
+   Hooks::run( 'BeforePageDisplay', [ &$outputPage, &$sk ] 
);
 
try {
$sk->outputPage();
diff --git a/includes/Revision.php b/includes/Revision.php
index 40daf3d..b4ca555 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -1457,7 +1457,9 @@
);
}
 
-   Hooks::run( 'RevisionInsertComplete', [ &$this, $data, $flags ] 
);
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $revision = $this;
+   Hooks::run( 'RevisionInsertComplete', [ &$revision, $data, 
$flags ] );
 
return $this->mId;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib3e6a288a423958e75b5c1bfe53dc29e0f3fee6d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Reedy 
Gerrit-Reviewer: Reedy 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org

[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_27]: Avoid passing $this by reference in hooks

2017-08-27 Thread Reedy (Code Review)
Reedy has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374093 )

Change subject: Avoid passing $this by reference in hooks
..

Avoid passing $this by reference in hooks

Renamed $this passed by reference usages in hooks inside includes directory

Bug: T153505
Change-Id: Ib3e6a288a423958e75b5c1bfe53dc29e0f3fee6d
(cherry picked from commit b98aa152b340b2e77a25c92c413d5950af5f4ca8)
---
M includes/Block.php
M includes/OutputPage.php
M includes/Revision.php
3 files changed, 18 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/93/374093/1

diff --git a/includes/Block.php b/includes/Block.php
index 79b31bb..827099a 100644
--- a/includes/Block.php
+++ b/includes/Block.php
@@ -741,8 +741,10 @@
return false;
}
 
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $block = $this;
# Allow hooks to cancel the autoblock.
-   if ( !Hooks::run( 'AbortAutoblock', [ $autoblockIP, &$this ] ) 
) {
+   if ( !Hooks::run( 'AbortAutoblock', [ $autoblockIP, &$block ] ) 
) {
wfDebug( "Autoblock aborted by hook.\n" );
return false;
}
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index e5be2c7..c04d3b4 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1311,10 +1311,12 @@
}
}
 
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
# Add the remaining categories to the skin
if ( Hooks::run(
'OutputPageMakeCategoryLinks',
-   [ &$this, $categories, &$this->mCategoryLinks ] )
+   [ &$outputPage, $categories, &$this->mCategoryLinks ] )
) {
foreach ( $categories as $category => $type ) {
// array keys will cast numeric category names 
to ints, so cast back to string
@@ -1810,8 +1812,10 @@
// Link flags are ignored for now, but may in the future be
// used to mark individual language links.
$linkFlags = [];
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
Hooks::run( 'LanguageLinks', [ $this->getTitle(), 
&$this->mLanguageLinks, &$linkFlags ] );
-   Hooks::run( 'OutputPageParserOutput', [ &$this, $parserOutput ] 
);
+   Hooks::run( 'OutputPageParserOutput', [ &$outputPage, 
$parserOutput ] );
}
 
/**
@@ -1839,7 +1843,9 @@
 */
public function addParserOutputText( $parserOutput ) {
$text = $parserOutput->getText();
-   Hooks::run( 'OutputPageBeforeHTML', [ &$this, &$text ] );
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
+   Hooks::run( 'OutputPageBeforeHTML', [ &$outputPage, &$text ] );
$this->addHTML( $text );
}
 
@@ -2319,9 +2325,11 @@
}
MWDebug::addModules( $this );
 
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $outputPage = $this;
// Hook that allows last minute changes to the output 
page, e.g.
// adding of CSS or Javascript by extensions.
-   Hooks::run( 'BeforePageDisplay', [ &$this, &$sk ] );
+   Hooks::run( 'BeforePageDisplay', [ &$outputPage, &$sk ] 
);
 
try {
$sk->outputPage();
diff --git a/includes/Revision.php b/includes/Revision.php
index 40daf3d..b4ca555 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -1457,7 +1457,9 @@
);
}
 
-   Hooks::run( 'RevisionInsertComplete', [ &$this, $data, $flags ] 
);
+   // Avoid PHP 7.1 warning of passing $this by reference
+   $revision = $this;
+   Hooks::run( 'RevisionInsertComplete', [ &$revision, $data, 
$flags ] );
 
return $this->mId;
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3e6a288a423958e75b5c1bfe53dc29e0f3fee6d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Reedy 

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