jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/335392 )
Change subject: Replace use of &$this
......................................................................
Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.
Bug: T153505
Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
---
M docs/hooks.txt
M includes/MagicWord.php
M includes/changes/ChangesList.php
M includes/changes/OldChangesList.php
M includes/changes/RecentChange.php
M includes/db/DatabaseOracle.php
M includes/deferred/LinksUpdate.php
M includes/diff/DifferenceEngine.php
M includes/export/XmlDumpWriter.php
M includes/filerepo/file/LocalFile.php
M includes/libs/rdbms/database/Database.php
M includes/libs/rdbms/database/DatabasePostgres.php
M includes/libs/replacers/Replacer.php
M includes/page/ImagePage.php
M includes/page/WikiPage.php
M includes/parser/DateFormatter.php
M includes/parser/LinkHolderArray.php
M includes/parser/Parser.php
M includes/resourceloader/ResourceLoader.php
M includes/skins/BaseTemplate.php
M includes/specials/SpecialMovepage.php
M includes/specials/SpecialWantedpages.php
M includes/specials/pagers/ContribsPager.php
M includes/specials/pagers/NewPagesPager.php
M languages/Language.php
25 files changed, 123 insertions(+), 57 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 27773f6..1459b89 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -212,9 +212,13 @@
# ...
function protect() {
global $wgUser;
- if ( Hooks::run( 'ArticleProtect', array( &$this,
&$wgUser ) ) ) {
+
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $article = $this;
+
+ if ( Hooks::run( 'ArticleProtect', [ &$article,
&$wgUser ] ) ) {
# protect the article
- Hooks::run( 'ArticleProtectComplete', array(
&$this, &$wgUser ) );
+ Hooks::run( 'ArticleProtectComplete', [
&$article, &$wgUser ] );
}
}
}
diff --git a/includes/MagicWord.php b/includes/MagicWord.php
index 5968e87..09317d7 100644
--- a/includes/MagicWord.php
+++ b/includes/MagicWord.php
@@ -526,7 +526,7 @@
$this->mFound = false;
$text = preg_replace_callback(
$this->getRegex(),
- [ &$this, 'pregRemoveAndRecord' ],
+ [ $this, 'pregRemoveAndRecord' ],
$text
);
@@ -541,7 +541,7 @@
$this->mFound = false;
$text = preg_replace_callback(
$this->getRegexStart(),
- [ &$this, 'pregRemoveAndRecord' ],
+ [ $this, 'pregRemoveAndRecord' ],
$text
);
diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php
index 77038ed..1e88e13 100644
--- a/includes/changes/ChangesList.php
+++ b/includes/changes/ChangesList.php
@@ -444,8 +444,10 @@
# TODO: Deprecate the $s argument, it seems happily unused.
$s = '';
+ # Avoid PHP 7.1 warning from passing $this by reference
+ $changesList = $this;
Hooks::run( 'ChangesListInsertArticleLink',
- [ &$this, &$articlelink, &$s, &$rc, $unpatrolled,
$watched ] );
+ [ &$changesList, &$articlelink, &$s, &$rc,
$unpatrolled, $watched ] );
return "{$s} {$articlelink}";
}
diff --git a/includes/changes/OldChangesList.php
b/includes/changes/OldChangesList.php
index 8eb06ce..d862ef4 100644
--- a/includes/changes/OldChangesList.php
+++ b/includes/changes/OldChangesList.php
@@ -50,7 +50,9 @@
$rc->mAttribs['rc_namespace'] . '-' .
$rc->mAttribs['rc_title'] );
}
- if ( !Hooks::run( 'OldChangesListRecentChangesLine', [ &$this,
&$html, $rc, &$classes ] ) ) {
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $list = $this;
+ if ( !Hooks::run( 'OldChangesListRecentChangesLine', [ &$list,
&$html, $rc, &$classes ] ) ) {
return false;
}
diff --git a/includes/changes/RecentChange.php
b/includes/changes/RecentChange.php
index 13a5fc7..772500f 100644
--- a/includes/changes/RecentChange.php
+++ b/includes/changes/RecentChange.php
@@ -329,7 +329,9 @@
$this->mAttribs['rc_id'] = $dbw->insertId();
# Notify extensions
- Hooks::run( 'RecentChange_save', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $rc = $this;
+ Hooks::run( 'RecentChange_save', [ &$rc ] );
if ( count( $this->tags ) ) {
ChangeTags::addTags( $this->tags,
$this->mAttribs['rc_id'],
diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php
index c3502f6..d8ed7a9 100644
--- a/includes/db/DatabaseOracle.php
+++ b/includes/db/DatabaseOracle.php
@@ -668,7 +668,7 @@
list( $startOpts, $useIndex, $tailOpts, $ignoreIndex ) =
$this->makeSelectOptions( $selectOptions );
if ( is_array( $srcTable ) ) {
- $srcTable = implode( ',', array_map( [ &$this,
'tableName' ], $srcTable ) );
+ $srcTable = implode( ',', array_map( [ $this,
'tableName' ], $srcTable ) );
} else {
$srcTable = $this->tableName( $srcTable );
}
@@ -998,7 +998,7 @@
private function fieldInfoMulti( $table, $field ) {
$field = strtoupper( $field );
if ( is_array( $table ) ) {
- $table = array_map( [ &$this, 'tableNameInternal' ],
$table );
+ $table = array_map( [ $this, 'tableNameInternal' ],
$table );
$tableWhere = 'IN (';
foreach ( $table as &$singleTable ) {
$singleTable = $this->removeIdentifierQuotes(
$singleTable );
diff --git a/includes/deferred/LinksUpdate.php
b/includes/deferred/LinksUpdate.php
index 229a9a2..464c908 100644
--- a/includes/deferred/LinksUpdate.php
+++ b/includes/deferred/LinksUpdate.php
@@ -154,7 +154,9 @@
$this->mRecursive = $recursive;
- Hooks::run( 'LinksUpdateConstructed', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $linksUpdate = $this;
+ Hooks::run( 'LinksUpdateConstructed', [ &$linksUpdate ] );
}
/**
@@ -169,7 +171,9 @@
$scopedLock = self::acquirePageLock( $this->getDB(),
$this->mId );
}
- Hooks::run( 'LinksUpdate', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $linksUpdate = $this;
+ Hooks::run( 'LinksUpdate', [ &$linksUpdate ] );
$this->doIncrementalUpdate();
// Commit and release the lock (if set)
@@ -177,7 +181,9 @@
// Run post-commit hooks without DBO_TRX
$this->getDB()->onTransactionIdle(
function () {
- Hooks::run( 'LinksUpdateComplete', [ &$this,
$this->ticket ] );
+ // Avoid PHP 7.1 warning from passing $this by
reference
+ $linksUpdate = $this;
+ Hooks::run( 'LinksUpdateComplete', [
&$linksUpdate, $this->ticket ] );
},
__METHOD__
);
diff --git a/includes/diff/DifferenceEngine.php
b/includes/diff/DifferenceEngine.php
index 559a5ec..5367199 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -762,8 +762,11 @@
$difftext = $this->generateContentDiffBody( $this->mOldContent,
$this->mNewContent );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $diffEngine = $this;
+
// Save to cache for 7 days
- if ( !Hooks::run( 'AbortDiffCache', [ &$this ] ) ) {
+ if ( !Hooks::run( 'AbortDiffCache', [ &$diffEngine ] ) ) {
wfIncrStats( 'diff_cache.uncacheable' );
} elseif ( $key !== false && $difftext !== false ) {
wfIncrStats( 'diff_cache.miss' );
@@ -982,7 +985,7 @@
public function localiseLineNumbers( $text ) {
return preg_replace_callback(
'/<!--LINE (\d+)-->/',
- [ &$this, 'localiseLineNumbersCb' ],
+ [ $this, 'localiseLineNumbersCb' ],
$text
);
}
diff --git a/includes/export/XmlDumpWriter.php
b/includes/export/XmlDumpWriter.php
index 5be166b..52bf0f0 100644
--- a/includes/export/XmlDumpWriter.php
+++ b/includes/export/XmlDumpWriter.php
@@ -269,7 +269,9 @@
$out .= " <sha1/>\n";
}
- Hooks::run( 'XmlDumpWriterWriteRevision', [ &$this, &$out,
$row, $text ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $writer = $this;
+ Hooks::run( 'XmlDumpWriterWriteRevision', [ &$writer, &$out,
$row, $text ] );
$out .= " </revision>\n";
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index be0751f..8c088b9 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1070,7 +1070,9 @@
$opts['ORDER BY'] = "oi_timestamp $order";
$opts['USE INDEX'] = [ 'oldimage' => 'oi_name_timestamp' ];
- Hooks::run( 'LocalFile::getHistory', [ &$this, &$tables,
&$fields,
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $localFile = $this;
+ Hooks::run( 'LocalFile::getHistory', [ &$localFile, &$tables,
&$fields,
&$conds, &$opts, &$join_conds ] );
$res = $dbr->select( $tables, $fields, $conds, __METHOD__,
$opts, $join_conds );
diff --git a/includes/libs/rdbms/database/Database.php
b/includes/libs/rdbms/database/Database.php
index 68d500b..d15d6f1 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -2314,7 +2314,7 @@
$selectOptions );
if ( is_array( $srcTable ) ) {
- $srcTable = implode( ',', array_map( [ &$this,
'tableName' ], $srcTable ) );
+ $srcTable = implode( ',', array_map( [ $this,
'tableName' ], $srcTable ) );
} else {
$srcTable = $this->tableName( $srcTable );
}
diff --git a/includes/libs/rdbms/database/DatabasePostgres.php
b/includes/libs/rdbms/database/DatabasePostgres.php
index 42113b0..75cc97c 100644
--- a/includes/libs/rdbms/database/DatabasePostgres.php
+++ b/includes/libs/rdbms/database/DatabasePostgres.php
@@ -698,7 +698,7 @@
list( $startOpts, $useIndex, $tailOpts, $ignoreIndex ) =
$this->makeSelectOptions( $selectOptions );
if ( is_array( $srcTable ) ) {
- $srcTable = implode( ',', array_map( [ &$this,
'tableName' ], $srcTable ) );
+ $srcTable = implode( ',', array_map( [ $this,
'tableName' ], $srcTable ) );
} else {
$srcTable = $this->tableName( $srcTable );
}
@@ -1257,7 +1257,7 @@
if ( isset( $options['FOR UPDATE'] ) ) {
$postLimitTail .= ' FOR UPDATE OF ' .
- implode( ', ', array_map( [ &$this, 'tableName'
], $options['FOR UPDATE'] ) );
+ implode( ', ', array_map( [ $this, 'tableName'
], $options['FOR UPDATE'] ) );
} elseif ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
$postLimitTail .= ' FOR UPDATE';
}
diff --git a/includes/libs/replacers/Replacer.php
b/includes/libs/replacers/Replacer.php
index 3b97835..655e771 100644
--- a/includes/libs/replacers/Replacer.php
+++ b/includes/libs/replacers/Replacer.php
@@ -27,7 +27,7 @@
* @return array
*/
public function cb() {
- return [ &$this, 'replace' ];
+ return [ $this, 'replace' ];
}
/**
diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php
index b60b010..c75cfdd 100644
--- a/includes/page/ImagePage.php
+++ b/includes/page/ImagePage.php
@@ -336,7 +336,7 @@
$filename = wfEscapeWikiText(
$this->displayImg->getName() );
$linktext = $filename;
- // Use of &$this in hooks triggers warnings in PHP 7.1
+ // Avoid PHP 7.1 warning from passing $this by reference
$imagePage = $this;
Hooks::run( 'ImageOpenShowImageInlineBefore', [
&$imagePage, &$out ] );
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 1c1412a..232f6cc 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -323,7 +323,7 @@
$row = $dbr->selectRow( 'page', $fields, $conditions,
__METHOD__, $options );
- Hooks::run( 'ArticlePageDataAfter', [ &$this, &$row ] );
+ Hooks::run( 'ArticlePageDataAfter', [ &$wikiPage, &$row ] );
return $row;
}
diff --git a/includes/parser/DateFormatter.php
b/includes/parser/DateFormatter.php
index 08e3c77..76ee525 100644
--- a/includes/parser/DateFormatter.php
+++ b/includes/parser/DateFormatter.php
@@ -197,7 +197,7 @@
// Another horrible hack
$this->mLinked = $linked;
- $text = preg_replace_callback( $regex, [ &$this,
'replace' ], $text );
+ $text = preg_replace_callback( $regex, [ $this,
'replace' ], $text );
unset( $this->mLinked );
}
return $text;
diff --git a/includes/parser/LinkHolderArray.php
b/includes/parser/LinkHolderArray.php
index e7712f2..d2a0a1a 100644
--- a/includes/parser/LinkHolderArray.php
+++ b/includes/parser/LinkHolderArray.php
@@ -613,7 +613,7 @@
public function replaceText( $text ) {
$text = preg_replace_callback(
'/<!--(LINK|IWLINK) (.*?)-->/',
- [ &$this, 'replaceTextCallback' ],
+ [ $this, 'replaceTextCallback' ],
$text );
return $text;
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 3ec0596..1d55c98 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -330,7 +330,9 @@
CoreTagHooks::register( $this );
$this->initialiseVariables();
- Hooks::run( 'ParserFirstCallInit', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserFirstCallInit', [ &$parser ] );
}
/**
@@ -381,7 +383,9 @@
$this->mProfiler = new SectionProfiler();
- Hooks::run( 'ParserClearState', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserClearState', [ &$parser ] );
}
/**
@@ -435,11 +439,13 @@
$this->mRevisionSize = null;
}
- Hooks::run( 'ParserBeforeStrip', [ &$this, &$text,
&$this->mStripState ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserBeforeStrip', [ &$parser, &$text,
&$this->mStripState ] );
# No more strip!
- Hooks::run( 'ParserAfterStrip', [ &$this, &$text,
&$this->mStripState ] );
+ Hooks::run( 'ParserAfterStrip', [ &$parser, &$text,
&$this->mStripState ] );
$text = $this->internalParse( $text );
- Hooks::run( 'ParserAfterParse', [ &$this, &$text,
&$this->mStripState ] );
+ Hooks::run( 'ParserAfterParse', [ &$parser, &$text,
&$this->mStripState ] );
$text = $this->internalParseHalfParsed( $text, true, $linestart
);
@@ -615,8 +621,10 @@
* @return string UNSAFE half-parsed HTML
*/
public function recursiveTagParse( $text, $frame = false ) {
- Hooks::run( 'ParserBeforeStrip', [ &$this, &$text,
&$this->mStripState ] );
- Hooks::run( 'ParserAfterStrip', [ &$this, &$text,
&$this->mStripState ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserBeforeStrip', [ &$parser, &$text,
&$this->mStripState ] );
+ Hooks::run( 'ParserAfterStrip', [ &$parser, &$text,
&$this->mStripState ] );
$text = $this->internalParse( $text, false, $frame );
return $text;
}
@@ -663,8 +671,10 @@
if ( $revid !== null ) {
$this->mRevisionId = $revid;
}
- Hooks::run( 'ParserBeforeStrip', [ &$this, &$text,
&$this->mStripState ] );
- Hooks::run( 'ParserAfterStrip', [ &$this, &$text,
&$this->mStripState ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserBeforeStrip', [ &$parser, &$text,
&$this->mStripState ] );
+ Hooks::run( 'ParserAfterStrip', [ &$parser, &$text,
&$this->mStripState ] );
$text = $this->replaceVariables( $text, $frame );
$text = $this->mStripState->unstripBoth( $text );
return $text;
@@ -1259,8 +1269,11 @@
$origText = $text;
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
# Hook to suspend the parser in this state
- if ( !Hooks::run( 'ParserBeforeInternalParse', [ &$this,
&$text, &$this->mStripState ] ) ) {
+ if ( !Hooks::run( 'ParserBeforeInternalParse', [ &$parser,
&$text, &$this->mStripState ] ) ) {
return $text;
}
@@ -1280,16 +1293,16 @@
$text = $this->replaceVariables( $text );
}
- Hooks::run( 'InternalParseBeforeSanitize', [ &$this, &$text,
&$this->mStripState ] );
+ Hooks::run( 'InternalParseBeforeSanitize', [ &$parser, &$text,
&$this->mStripState ] );
$text = Sanitizer::removeHTMLtags(
$text,
- [ &$this, 'attributeStripCallback' ],
+ [ $this, 'attributeStripCallback' ],
false,
array_keys( $this->mTransparentTagHooks ),
[],
- [ &$this, 'addTrackingCategory' ]
+ [ $this, 'addTrackingCategory' ]
);
- Hooks::run( 'InternalParseBeforeLinks', [ &$this, &$text,
&$this->mStripState ] );
+ Hooks::run( 'InternalParseBeforeLinks', [ &$parser, &$text,
&$this->mStripState ] );
# Tables need to come after variable replacement for things to
work
# properly; putting them before other transformations should
keep
@@ -1328,8 +1341,11 @@
private function internalParseHalfParsed( $text, $isMain = true,
$linestart = true ) {
$text = $this->mStripState->unstripGeneral( $text );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
if ( $isMain ) {
- Hooks::run( 'ParserAfterUnstrip', [ &$this, &$text ] );
+ Hooks::run( 'ParserAfterUnstrip', [ &$parser, &$text ]
);
}
# Clean up special characters, only run once, next-to-last
before doBlockLevels
@@ -1368,7 +1384,7 @@
$text = $this->mStripState->unstripNoWiki( $text );
if ( $isMain ) {
- Hooks::run( 'ParserBeforeTidy', [ &$this, &$text ] );
+ Hooks::run( 'ParserBeforeTidy', [ &$parser, &$text ] );
}
$text = $this->replaceTransparentTags( $text );
@@ -1409,7 +1425,7 @@
}
if ( $isMain ) {
- Hooks::run( 'ParserAfterTidy', [ &$this, &$text ] );
+ Hooks::run( 'ParserAfterTidy', [ &$parser, &$text ] );
}
return $text;
@@ -1447,7 +1463,7 @@
(?: [0-9] $spdash? ){9} # 9 digits
with opt. delimiters
[0-9Xx] # check digit
)\b
- )!xu", [ &$this, 'magicLinkCallback' ], $text );
+ )!xu", [ $this, 'magicLinkCallback' ], $text );
return $text;
}
@@ -2486,18 +2502,21 @@
. ' called while parsing (no title set)' );
}
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
/**
* Some of these require message or data lookups and can be
* expensive to check many times.
*/
- if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$this,
&$this->mVarCache ] ) ) {
+ if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$parser,
&$this->mVarCache ] ) ) {
if ( isset( $this->mVarCache[$index] ) ) {
return $this->mVarCache[$index];
}
}
$ts = wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() );
- Hooks::run( 'ParserGetVariableValueTs', [ &$this, &$ts ] );
+ Hooks::run( 'ParserGetVariableValueTs', [ &$parser, &$ts ] );
$pageLang = $this->getFunctionLang();
@@ -2810,7 +2829,7 @@
$ret = null;
Hooks::run(
'ParserGetVariableValueSwitch',
- [ &$this, &$this->mVarCache, &$index,
&$ret, &$frame ]
+ [ &$parser, &$this->mVarCache, &$index,
&$ret, &$frame ]
);
return $ret;
@@ -3354,7 +3373,10 @@
throw new MWException( "Tag hook for $function is not
callable\n" );
}
- $allArgs = [ &$this ];
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
+ $allArgs = [ &$parser ];
if ( $flags & self::SFH_OBJECT_ARGS ) {
# Convert arguments to PPNodes and collect for
appending to $allArgs
$funcArgs = [];
@@ -3863,7 +3885,9 @@
throw new MWException( "Tag hook for
$name is not callable\n" );
}
- $output = call_user_func_array( $callback, [
&$this, $frame, $content, $attributes ] );
+ // Avoid PHP 7.1 warning from passing $this by
reference
+ $parser = $this;
+ $output = call_user_func_array( $callback, [
&$parser, $frame, $content, $attributes ] );
} else {
$output = '<span class="error">Invalid tag
extension name: ' .
htmlspecialchars( $name ) . '</span>';
@@ -4966,7 +4990,9 @@
}
$ig->setAdditionalOptions( $params );
- Hooks::run( 'BeforeParserrenderImageGallery', [ &$this, &$ig ]
);
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'BeforeParserrenderImageGallery', [ &$parser, &$ig
] );
$lines = StringUtils::explode( "\n", $text );
foreach ( $lines as $line ) {
diff --git a/includes/resourceloader/ResourceLoader.php
b/includes/resourceloader/ResourceLoader.php
index f0b48d5..a55cbc1 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -255,7 +255,10 @@
$this->register( include "$IP/resources/ResourcesOOUI.php" );
// Register extension modules
$this->register( $config->get( 'ResourceModules' ) );
- Hooks::run( 'ResourceLoaderRegisterModules', [ &$this ] );
+
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $rl = $this;
+ Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
$this->registerTestModules();
@@ -404,7 +407,9 @@
$testModules = [];
$testModules['qunit'] = [];
// Get other test suites (e.g. from extensions)
- Hooks::run( 'ResourceLoaderTestModules', [ &$testModules,
&$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $rl = $this;
+ Hooks::run( 'ResourceLoaderTestModules', [ &$testModules, &$rl
] );
// Add the testrunner (which configures QUnit) to the
dependencies.
// Since it must be ready before any of the test suites are
executed.
diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php
index 65eb9b7..eef421c 100644
--- a/includes/skins/BaseTemplate.php
+++ b/includes/skins/BaseTemplate.php
@@ -112,7 +112,9 @@
$toolbox['info']['id'] = 't-info';
}
- Hooks::run( 'BaseTemplateToolbox', [ &$this, &$toolbox ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $template = $this;
+ Hooks::run( 'BaseTemplateToolbox', [ &$template, &$toolbox ] );
return $toolbox;
}
@@ -227,7 +229,9 @@
ob_start();
// We pass an extra 'true' at the end so extensions
using BaseTemplateToolbox
// can abort and avoid outputting double toolbox links
- Hooks::run( 'SkinTemplateToolboxEnd', [ &$this, true ]
);
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $template = $this;
+ Hooks::run( 'SkinTemplateToolboxEnd', [ &$template,
true ] );
$hookContents = ob_get_contents();
ob_end_clean();
if ( !trim( $hookContents ) ) {
diff --git a/includes/specials/SpecialMovepage.php
b/includes/specials/SpecialMovepage.php
index 298d6c4..0281b15 100644
--- a/includes/specials/SpecialMovepage.php
+++ b/includes/specials/SpecialMovepage.php
@@ -630,7 +630,9 @@
$newLink )->params( $oldText, $newText
)->parseAsBlock() );
$out->addWikiMsg( $msgName );
- Hooks::run( 'SpecialMovepageAfterMove', [ &$this, &$ot, &$nt ]
);
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $movePage = $this;
+ Hooks::run( 'SpecialMovepageAfterMove', [ &$movePage, &$ot,
&$nt ] );
# Now we move extra pages we've been asked to move: subpages
and talk
# pages. First, if the old page or the new page is a talk
page, we
diff --git a/includes/specials/SpecialWantedpages.php
b/includes/specials/SpecialWantedpages.php
index c37ecbd..8cea6cc 100644
--- a/includes/specials/SpecialWantedpages.php
+++ b/includes/specials/SpecialWantedpages.php
@@ -85,7 +85,9 @@
]
];
// Replacement for the WantedPages::getSQL hook
- Hooks::run( 'WantedPages::getQueryInfo', [ &$this, &$query ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $wantedPages = $this;
+ Hooks::run( 'WantedPages::getQueryInfo', [ &$wantedPages,
&$query ] );
return $query;
}
diff --git a/includes/specials/pagers/ContribsPager.php
b/includes/specials/pagers/ContribsPager.php
index 367d073..0c3a211 100644
--- a/includes/specials/pagers/ContribsPager.php
+++ b/includes/specials/pagers/ContribsPager.php
@@ -200,7 +200,9 @@
$this->tagFilter
);
- Hooks::run( 'ContribsPager::getQueryInfo', [ &$this,
&$queryInfo ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $pager = $this;
+ Hooks::run( 'ContribsPager::getQueryInfo', [ &$pager,
&$queryInfo ] );
return $queryInfo;
}
diff --git a/includes/specials/pagers/NewPagesPager.php
b/includes/specials/pagers/NewPagesPager.php
index e298f10..dafd244 100644
--- a/includes/specials/pagers/NewPagesPager.php
+++ b/includes/specials/pagers/NewPagesPager.php
@@ -100,8 +100,10 @@
];
$join_conds = [ 'page' => [ 'INNER JOIN', 'page_id=rc_cur_id' ]
];
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $pager = $this;
Hooks::run( 'SpecialNewpagesConditions',
- [ &$this, $this->opts, &$conds, &$tables, &$fields,
&$join_conds ] );
+ [ &$pager, $this->opts, &$conds, &$tables, &$fields,
&$join_conds ] );
$options = [];
diff --git a/languages/Language.php b/languages/Language.php
index 68727bb..a1cc4bc 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -4508,7 +4508,7 @@
# such as action=raw much more expensive than they need to be.
# This will hopefully cover most cases.
$talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i',
- [ &$this, 'replaceGrammarInNamespace' ], $talk );
+ [ $this, 'replaceGrammarInNamespace' ], $talk );
return str_replace( ' ', '_', $talk );
}
--
To view, visit https://gerrit.wikimedia.org/r/335392
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: C. Scott Ananian <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits