# ...
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 ] );
}
}
}
$this->mFound = false;
$text = preg_replace_callback(
$this->getRegex(),
- [ &$this, 'pregRemoveAndRecord' ],
+ [ $this, 'pregRemoveAndRecord' ],
$text
);
$this->mFound = false;
$text = preg_replace_callback(
$this->getRegexStart(),
- [ &$this, 'pregRemoveAndRecord' ],
+ [ $this, 'pregRemoveAndRecord' ],
$text
);
# 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}";
}
$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;
}
$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'],
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 );
}
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 );
$this->mRecursive = $recursive;
- Hooks::run( 'LinksUpdateConstructed', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $linksUpdate = $this;
+ Hooks::run( 'LinksUpdateConstructed', [ &$linksUpdate ] );
}
/**
$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)
// 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__
);
$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' );
public function localiseLineNumbers( $text ) {
return preg_replace_callback(
'/<!--LINE (\d+)-->/',
- [ &$this, 'localiseLineNumbersCb' ],
+ [ $this, 'localiseLineNumbersCb' ],
$text
);
}
$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";
$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 );
$selectOptions );
if ( is_array( $srcTable ) ) {
- $srcTable = implode( ',', array_map( [ &$this, 'tableName' ], $srcTable ) );
+ $srcTable = implode( ',', array_map( [ $this, 'tableName' ], $srcTable ) );
} else {
$srcTable = $this->tableName( $srcTable );
}
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 );
}
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';
}
* @return array
*/
public function cb() {
- return [ &$this, 'replace' ];
+ return [ $this, 'replace' ];
}
/**
$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 ] );
$row = $dbr->selectRow( 'page', $fields, $conditions, __METHOD__, $options );
- Hooks::run( 'ArticlePageDataAfter', [ &$this, &$row ] );
+ Hooks::run( 'ArticlePageDataAfter', [ &$wikiPage, &$row ] );
return $row;
}
// 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;
public function replaceText( $text ) {
$text = preg_replace_callback(
'/<!--(LINK|IWLINK) (.*?)-->/',
- [ &$this, 'replaceTextCallback' ],
+ [ $this, 'replaceTextCallback' ],
$text );
return $text;
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 ] );
}
/**
$this->mProfiler = new SectionProfiler();
- Hooks::run( 'ParserClearState', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserClearState', [ &$parser ] );
}
/**
$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 );
* @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;
}
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;
$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;
}
$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
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
$text = $this->mStripState->unstripNoWiki( $text );
if ( $isMain ) {
- Hooks::run( 'ParserBeforeTidy', [ &$this, &$text ] );
+ Hooks::run( 'ParserBeforeTidy', [ &$parser, &$text ] );
}
$text = $this->replaceTransparentTags( $text );
}
if ( $isMain ) {
- Hooks::run( 'ParserAfterTidy', [ &$this, &$text ] );
+ Hooks::run( 'ParserAfterTidy', [ &$parser, &$text ] );
}
return $text;
(?: [0-9] $spdash? ){9} # 9 digits with opt. delimiters
[0-9Xx] # check digit
)\b
- )!xu", [ &$this, 'magicLinkCallback' ], $text );
+ )!xu", [ $this, 'magicLinkCallback' ], $text );
return $text;
}
. ' 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();
$ret = null;
Hooks::run(
'ParserGetVariableValueSwitch',
- [ &$this, &$this->mVarCache, &$index, &$ret, &$frame ]
+ [ &$parser, &$this->mVarCache, &$index, &$ret, &$frame ]
);
return $ret;
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 = [];
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>';
}
$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 ) {
$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();
$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.
$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;
}
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 ) ) {
$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
]
];
// 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;
}
$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;
}
];
$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 = [];
# 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 );
}