Pass $parser, &$query and &$widthOption to the 'ImageBeforeProduceHTML' hook
authorJack Phoenix <ashley@uncyclomedia.co>
Sun, 10 Jun 2018 15:31:56 +0000 (18:31 +0300)
committerJack Phoenix <ashley@uncyclomedia.co>
Sun, 10 Jun 2018 15:31:56 +0000 (18:31 +0300)
This allows extensions to essentially reimplement Linker#makeImageLink
completely. Before this wasn't 100% possible as these three are needed for
that.

Inspired by wikiHow's core hacks to /includes/Linker.php, which can now be
moved to an ImageBeforeProduceHTML hook subscriber. wikiHow uses those
changes together with the WikihowArticle extension to heavily modify the
article DOM for various extensions and the default skin.

Change-Id: I8b5ab42d9cf021d66b90d15be68a0239643c10e3

RELEASE-NOTES-1.32
docs/hooks.txt
includes/Linker.php

index cdc2582..e276a19 100644 (file)
@@ -41,6 +41,9 @@ production.
   reauthenticating.
 * FormSpecialPage::execute() will now call checkLoginSecurityLevel() if
   getLoginSecurityLevel() returns non-false.
+* The 'ImageBeforeProduceHTML' hook is now passed three new parameters, $parser,
+  &$query and &$widthOption, allowing extensions even finer control over the resulting
+  HTML code.
 
 === External library changes in 1.32 ===
 * …
index 8c84509..bd237e6 100644 (file)
@@ -1826,6 +1826,9 @@ just modify a few things using call-by-reference.
   includes/Linker.php for Linker::makeImageLink
 &$time: Timestamp of file in 'YYYYMMDDHHIISS' string form, or false for current
 &$res: Final HTML output, used if you return false
+$parser: Parser instance
+&$query: Query params for desc URL
+&$widthOption: Used by the parser to remember the user preference thumbnailsize
 
 'ImageOpenShowImageInlineBefore': Call potential extension just before showing
 the image on an image page.
index 9638502..b50ccfc 100644 (file)
@@ -328,7 +328,9 @@ class Linker {
                $res = null;
                $dummy = new DummyLinker;
                if ( !Hooks::run( 'ImageBeforeProduceHTML', [ &$dummy, &$title,
-                       &$file, &$frameParams, &$handlerParams, &$time, &$res ] ) ) {
+                       &$file, &$frameParams, &$handlerParams, &$time, &$res,
+                       $parser, &$query, &$widthOption
+               ] ) ) {
                        return $res;
                }