X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=maintenance%2FpopulateInterwiki.php;h=acc66c5199b89f694d6a4dabf2be48f15330c53e;hb=e9ed100496b388a31ac2af0deabcc9754984d09d;hp=5d32b998bd73e9af6b6d520fd282a59678aeb8d8;hpb=6186cfef91f5f33f56beb886a542f06ea2350850;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateInterwiki.php b/maintenance/populateInterwiki.php index 5d32b998bd..acc66c5199 100644 --- a/maintenance/populateInterwiki.php +++ b/maintenance/populateInterwiki.php @@ -24,6 +24,8 @@ * @author Katie Filbert < aude.wiki@gmail.com > */ +use MediaWiki\MediaWikiServices; + require_once __DIR__ . '/Maintenance.php'; class PopulateInterwiki extends Maintenance { @@ -33,11 +35,6 @@ class PopulateInterwiki extends Maintenance { */ private $source; - /** - * @var BagOStuff - */ - private $cache; - public function __construct() { parent::__construct(); @@ -61,11 +58,9 @@ TEXT } public function execute() { - $force = $this->getOption( 'force', false ); + $force = $this->hasOption( 'force' ); $this->source = $this->getOption( 'source', 'https://en.wikipedia.org/w/api.php' ); - $this->cache = wfGetMainCache(); - $data = $this->fetchLinks(); if ( $data === false ) { @@ -126,6 +121,7 @@ TEXT } } + $lookup = MediaWikiServices::getInstance()->getInterwikiLookup(); foreach ( $data as $d ) { $prefix = $d['prefix']; @@ -136,7 +132,7 @@ TEXT __METHOD__ ); - if ( ! $row ) { + if ( !$row ) { $dbw->insert( 'interwiki', [ @@ -149,7 +145,7 @@ TEXT ); } - $this->clearCacheEntry( $prefix ); + $lookup->invalidateCache( $prefix ); } $this->output( "Interwiki links are populated.\n" ); @@ -157,14 +153,6 @@ TEXT return true; } - /** - * @param string $prefix - */ - private function clearCacheEntry( $prefix ) { - $key = wfMemcKey( 'interwiki', $prefix ); - $this->cache->delete( $key ); - } - } $maintClass = PopulateInterwiki::class;