Thiemo Mättig (WMDE) has submitted this change and it was merged. Change subject: Purge interwiki memcached entries in populateInterwiki script ......................................................................
Purge interwiki memcached entries in populateInterwiki script Bug: 69903 Change-Id: I34a4bb97f32ca649b81f8917bd3c2a85caa4975c --- M client/maintenance/populateInterwiki.php 1 file changed, 23 insertions(+), 3 deletions(-) Approvals: WikidataJenkins: Verified Thiemo Mättig (WMDE): Looks good to me, approved jenkins-bot: Checked diff --git a/client/maintenance/populateInterwiki.php b/client/maintenance/populateInterwiki.php index 1f618cf..0c63025 100644 --- a/client/maintenance/populateInterwiki.php +++ b/client/maintenance/populateInterwiki.php @@ -21,6 +21,11 @@ */ private $source; + /** + * @var BagOStuff + */ + private $cache; + public function __construct() { $this->mDescription = <<<TEXT This script will populate the interwiki table, pulling in interwiki links that are used on Wikipedia @@ -46,6 +51,8 @@ $force = $this->getOption( 'force', false ); $this->source = $this->getOption( 'source', 'https://en.wikipedia.org/w/api.php' ); + $this->cache = wfGetMainCache(); + $data = $this->fetchLinks(); if ( $data === false ) { @@ -64,7 +71,6 @@ 'format' => 'json' ); - // todo: is valid if ( !empty( $this->source ) ) { try { $baseUrl = rtrim( $this->source, '?' ) . '?'; @@ -105,17 +111,20 @@ } foreach( $data as $d ) { + $prefix = $d['prefix']; + $row = $dbw->selectRow( 'interwiki', '1', - array( 'iw_prefix' => $d['prefix'] ), + array( 'iw_prefix' => $prefix ), __METHOD__ ); if ( ! $row ) { $dbw->insert( 'interwiki', - array( 'iw_prefix' => $d['prefix'], + array( + 'iw_prefix' => $prefix, 'iw_url' => $d['url'], 'iw_local' => 1 ), @@ -123,12 +132,23 @@ 'IGNORE' ); } + + $this->clearCacheEntry( $prefix ); } $this->output( "Interwiki links are populated.\n" ); return true; } + + /** + * @param string $prefix + */ + private function clearCacheEntry( $prefix ) { + $key = wfMemcKey( 'interwiki', $prefix ); + $this->cache->delete( $key ); + } + } $maintClass = 'PopulateInterwiki'; -- To view, visit https://gerrit.wikimedia.org/r/155734 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I34a4bb97f32ca649b81f8917bd3c2a85caa4975c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits