mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions
synced 2024-11-14 11:18:47 +00:00
Inject service LinkCache
Change-Id: I254a4a20bac60eb505c30ddbf0fd1f5aea9bdd04
This commit is contained in:
parent
4cf0a84ebd
commit
0f4984dc86
|
@ -40,6 +40,7 @@
|
|||
"class": "MediaWiki\\Extension\\ParserFunctions\\Hooks",
|
||||
"services": [
|
||||
"MainConfig",
|
||||
"LinkCache",
|
||||
"RepoGroup",
|
||||
"SpecialPageFactory"
|
||||
]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace MediaWiki\Extension\ParserFunctions;
|
||||
|
||||
use Config;
|
||||
use LinkCache;
|
||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||
use Parser;
|
||||
use RepoGroup;
|
||||
|
@ -20,17 +21,20 @@ class Hooks implements
|
|||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param LinkCache $linkCache
|
||||
* @param RepoGroup $repoGroup
|
||||
* @param SpecialPageFactory $specialPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Config $config,
|
||||
LinkCache $linkCache,
|
||||
RepoGroup $repoGroup,
|
||||
SpecialPageFactory $specialPageFactory
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->parserFunctions = new ParserFunctions(
|
||||
$config,
|
||||
$linkCache,
|
||||
$repoGroup,
|
||||
$specialPageFactory
|
||||
);
|
||||
|
|
|
@ -8,6 +8,7 @@ use DateTimeZone;
|
|||
use Exception;
|
||||
use ILanguageConverter;
|
||||
use Language;
|
||||
use LinkCache;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||
use MWTimestamp;
|
||||
|
@ -37,6 +38,9 @@ class ParserFunctions {
|
|||
/** @var Config */
|
||||
private $config;
|
||||
|
||||
/** @var LinkCache */
|
||||
private $linkCache;
|
||||
|
||||
/** @var RepoGroup */
|
||||
private $repoGroup;
|
||||
|
||||
|
@ -45,15 +49,18 @@ class ParserFunctions {
|
|||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param LinkCache $linkCache
|
||||
* @param RepoGroup $repoGroup
|
||||
* @param SpecialPageFactory $specialPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Config $config,
|
||||
LinkCache $linkCache,
|
||||
RepoGroup $repoGroup,
|
||||
SpecialPageFactory $specialPageFactory
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->linkCache = $linkCache;
|
||||
$this->repoGroup = $repoGroup;
|
||||
$this->specialPageFactory = $specialPageFactory;
|
||||
}
|
||||
|
@ -383,12 +390,11 @@ class ParserFunctions {
|
|||
return false;
|
||||
} else {
|
||||
$pdbk = $title->getPrefixedDBkey();
|
||||
$lc = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$id = $lc->getGoodLinkID( $pdbk );
|
||||
$id = $this->linkCache->getGoodLinkID( $pdbk );
|
||||
if ( $id !== 0 ) {
|
||||
$parser->getOutput()->addLink( $title, $id );
|
||||
return true;
|
||||
} elseif ( $lc->isBadLink( $pdbk ) ) {
|
||||
} elseif ( $this->linkCache->isBadLink( $pdbk ) ) {
|
||||
$parser->getOutput()->addLink( $title, 0 );
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue