Wikimedia
Remove use of &$this in hooks as it triggers warnings in PHP 7.1 (#5)
Code like Hooks::run( 'WantedPages::getQueryInfo', [ &$this, &$query ] );
will trigger warnings in PHP 7.1. Ideally the solution would be to remove &
, which hasn't been needed since PHP 4, however that breaks backwards-compatibility.
Instead, we can rename $this to a different variable, and then pass it by reference. Example:
// Avoid PHP 7.1 warning of passing $this by reference
$editPage = $this;
Hooks::run( 'EditPage::showEditForm:initial', [ &$editPage, &$out ] );
See https://bugs.php.net/bug.php?id=73751 / https://wiki.php.net/rfc/this_var
Example commit: https://gerrit.wikimedia.org/r/#/c/328387/
More information:
- https://secure.php.net/manual/en/migration71.incompatible.php
- https://blog.pascal-martin.fr/post/php71-en-a-few-bc-breaks-and-conclusion.html
You are expected to provide patches in Wikimedia Gerrit (one patch for each repository). See https://www.mediawiki.org/wiki/Gerrit/Tutorial for how to set up Git and Gerrit.
The repositories / files to fix for this task are:
- skins/apex/ApexTemplate.php: Hooks::run( $hook, [ &$this, true ] );
- skins/Truglass/includes/TruglassTemplate.php: Hooks::run( 'SkinTemplateToolboxEnd', array( &$this, true ) );
- skins/DeskMessMirrored/includes/DeskMessMirroredTemplate.php: Hooks::run( 'SkinTemplateToolboxEnd', array( &$this, true ) );
Task tags
Students who completed this task
Lukas A