From 7b3da79f507d2211ac66fd8255b5b273b6c4262f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 30 Jul 2018 17:25:25 +0200 Subject: [PATCH] Pass $title to 'GetLinkColours' hook I think it's reasonable for link "colours" to depend on the page on which they are shown. It seems similar to how self-links are handled. The $colours variable is not cached, so title-specific link colours will not "leak" to other titles. Used in ProofreadPage in Ic910c2c33a6f1f8a70d9a122fbd2128428f29bd5. Bug: T199288 Change-Id: I7378102a3e06544e9e695b255982c9bb0cfbf3a2 --- RELEASE-NOTES-1.32 | 2 ++ docs/hooks.txt | 1 + includes/parser/LinkHolderArray.php | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 9c6609bec9..193ede8eb9 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -66,6 +66,8 @@ production. remove or otherwise alter the elements to be output in the page . * (T28934) The 'HistoryPageToolLinks' hook allows extensions to append additional links to the subtitle of a history page. +* The 'GetLinkColours' hook now receives an additional $title parameter, + the Title object of the page being parsed, on which the links will be shown. === External library changes in 1.32 === * … diff --git a/docs/hooks.txt b/docs/hooks.txt index 251bea6581..219c51f30e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1730,6 +1730,7 @@ $query: query options passed to Title::getInternalURL() $linkcolour_ids: array of prefixed DB keys of the pages linked to, indexed by page_id. &$colours: (output) array of CSS classes, indexed by prefixed DB keys +$title: Title object of the page being parsed, on which the links will be shown 'GetLocalURL': Modify local URLs as output into page links. Note that if you are working with internal urls (non-interwiki) then it may be preferable to work diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 7e150e9cab..66fd723384 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -360,7 +360,7 @@ class LinkHolderArray { } if ( count( $linkcolour_ids ) ) { // pass an array of page_ids to an extension - Hooks::run( 'GetLinkColours', [ $linkcolour_ids, &$colours ] ); + Hooks::run( 'GetLinkColours', [ $linkcolour_ids, &$colours, $this->parent->getTitle() ] ); } # Do a second query for different language variants of links and categories @@ -589,7 +589,7 @@ class LinkHolderArray { } } } - Hooks::run( 'GetLinkColours', [ $linkcolour_ids, &$colours ] ); + Hooks::run( 'GetLinkColours', [ $linkcolour_ids, &$colours, $this->parent->getTitle() ] ); // rebuild the categories in original order (if there are replacements) if ( count( $varCategories ) > 0 ) { -- 2.20.1