Wikimedia

Replace &$this with $this in MediaWiki/core hook system

With PHP 7.1, passing $this as a reference to a function call (e.g. in call_user_func_array()) will emit a warning or throw a fatal error, see: https://bugs.php.net/bug.php?id=73751 https://wiki.php.net/rfc/this_var

MediaWiki provides a Hook system, so that an extension can hook into a specific execution point and run arbitrary code in this specific context to change or extend the behavior of MediaWiki. A Hook has a specific signature (a name and parameters). These parameters are variables, that will be passed to a registered hook listener, which then can use these variables and objects to interact with. Variables may be passed by reference, so that the registered hook can change values of objects.

Your task is to find at least two usages of $this passed by reference (&$this) in the Hook-system of MediaWiki (look for calls to Hook::run(), where the arguments are passed). You need also to check, if a hook listener (e.g. some extensions) rely on the value being passed by reference and also need to adjust the code, that it doesn't do so anymore. Your friend in both cases could be github, if you don't want to clone all extension repositories to your local computer.

This will improve the compatibility of MediaWiki with future php versions.

Task tags

  • hook
  • php
  • reference
  • technical debt

Students who completed this task

Andrew Wu, Justin Du, Geoffrey Mon, Victor Barbu, Filip, Yurii Shnitkovskyi, Subin Siby, David Sn

Task type

  • code Code
close

2016