diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f814e7..844961a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## ChangeLog for RottenLinks +### 2.0.1 (16-12-2023) +* Add `requireExtension` to updateExternalLinks. +* Remove unnecessary object cache from being added in updateExternalLinks. +* Prevent duplicate entries from being added to rottenlinks table in updateExternalLinks. +* Fix table name used in RottenLinksJob. + ### 2.0.0 (15-12-2023) * Redesign RottenLinks to not depend on a maintenance script * Changes how we count page usage on RottenLinks special page. We directly gather this from externallinks table rather then storing it separately. diff --git a/extension.json b/extension.json index 82d1637..8543fb6 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "RottenLinks", - "version": "2.0.0", + "version": "2.0.1", "author": [ "John Lewis", "Paladox", diff --git a/includes/RottenLinksJob.php b/includes/RottenLinksJob.php index 8a74d85..f73e6fc 100644 --- a/includes/RottenLinksJob.php +++ b/includes/RottenLinksJob.php @@ -62,13 +62,13 @@ public function run() { $rottenLinksCount = $dbw->newSelectQueryBuilder() ->select( 'rl_externallink' ) - ->from( 'externallinks' ) + ->from( 'rottenlinks' ) ->where( [ 'rl_externallink' => $url ] ) ->caller( __METHOD__ ) ->fetchRowCount(); if ( $rottenLinksCount > 0 ) { - // Don't create duplicate entires + // Don't create duplicate entries continue; } diff --git a/maintenance/updateExternalLinks.php b/maintenance/updateExternalLinks.php index c939042..3b25c9b 100644 --- a/maintenance/updateExternalLinks.php +++ b/maintenance/updateExternalLinks.php @@ -4,7 +4,6 @@ use Maintenance; use MediaWiki\MediaWikiServices; -use ObjectCache; use WikiForge\RottenLinks\RottenLinks; $IP = getenv( 'MW_INSTALL_PATH' ); @@ -19,6 +18,8 @@ public function __construct() { parent::__construct(); $this->addDescription( 'Updates rottenlinks database table based on externallinks table.' ); + + $this->requireExtension( 'RottenLinks' ); } public function execute() { @@ -72,6 +73,18 @@ public function execute() { continue; } + $rottenLinksCount = $dbw->newSelectQueryBuilder() + ->select( 'rl_externallink' ) + ->from( 'rottenlinks' ) + ->where( [ 'rl_externallink' => $url ] ) + ->caller( __METHOD__ ) + ->fetchRowCount(); + + if ( $rottenLinksCount > 0 ) { + // Don't create duplicate entries + continue; + } + $resp = RottenLinks::getResponse( $url ); $pagecount = count( $pages ); @@ -88,10 +101,6 @@ public function execute() { $time = time() - $time; - $cache = ObjectCache::getLocalClusterInstance(); - $cache->set( $cache->makeKey( 'RottenLinks', 'lastRun' ), $dbw->timestamp() ); - $cache->set( $cache->makeKey( 'RottenLinks', 'runTime' ), $time ); - $this->output( "Script took {$time} seconds.\n" ); }