Skip to content

Commit

Permalink
Use injected Lookup service; remove deprecated method
Browse files Browse the repository at this point in the history
The only production user of the deprecated
Hooks::isDisambiguationPage() method is the RelatedArticles extension;
the 'depends-on' patch here tweaks it to use the DisambiguatorLookup
service instead.

A similar patch to fix up a 3rd-party extension is at:
femiwiki/UnifiedExtensionForFemiwiki#139

This continues the slow cleanup moving to injected services from
globals.

Depends-On: Id2a10f2f1be0e38ddb8ebef5d5babb3daac3ce9a
Change-Id: I7f74c0c6347e7c5fea10c49aef665558762711d0
  • Loading branch information
cscott committed Feb 2, 2024
1 parent 3c1197b commit 0531c11
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions includes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,6 @@ public function onRandomPageQuery( &$tables, &$conds, &$joinConds ) {
self::excludeDisambiguationPages( $tables, $conds, $joinConds );
}

/**
* Convenience function for testing whether or not a page is a disambiguation page
*
* @deprecated Use DisambiguatorLookup service
*
* @param Title $title object of a page
* @param bool $includeRedirects Whether to consider redirects to disambiguations as
* disambiguations.
* @return bool
*/
public static function isDisambiguationPage( Title $title, $includeRedirects = true ) {
return MediaWikiServices::getInstance()->getService( 'DisambiguatorLookup' )
->isDisambiguationPage( $title, $includeRedirects );
}

/**
* Add 'mw-disambig' CSS class to links to disambiguation pages.
* @param array $pageIdToDbKey Prefixed DB keys of the pages linked to, indexed by page_id
Expand All @@ -168,8 +153,9 @@ public function onGetLinkColours( $pageIdToDbKey, &$colours, $title ) {
return;
}

$pageIds = MediaWikiServices::getInstance()->getService( 'DisambiguatorLookup' )
->filterDisambiguationPageIds( array_keys( $pageIdToDbKey ) );
$pageIds = $this->lookup->filterDisambiguationPageIds(
array_keys( $pageIdToDbKey )
);

foreach ( $pageIds as $pageId ) {
if ( isset( $colours[ $pageIdToDbKey[$pageId] ] ) ) {
Expand Down

0 comments on commit 0531c11

Please sign in to comment.