From: Kosta Harlan Date: Sun, 16 Jun 2019 23:00:52 +0000 (-0400) Subject: Only attempt to deduplicate if there is data in archive and revision X-Git-Tag: 1.34.0-rc.0~1388 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=53ba45d5d9ff4353c3edd3698c9b89b6b9653dd9;p=lhc%2Fweb%2Fwiklou.git Only attempt to deduplicate if there is data in archive and revision The idea is to avoid expensive calls to makeDummyRevisionRow, and speed up installation of MediaWiki on CI. Bug: T225901 Change-Id: I6f69281568218c89eb18353c06cabf7eb1926de8 --- diff --git a/maintenance/deduplicateArchiveRevId.php b/maintenance/deduplicateArchiveRevId.php index 2442caa7e0..a1d4e997fd 100644 --- a/maintenance/deduplicateArchiveRevId.php +++ b/maintenance/deduplicateArchiveRevId.php @@ -33,8 +33,13 @@ class DeduplicateArchiveRevId extends LoggedUpdateMaintenance { protected function doDBUpdates() { $this->output( "Deduplicating ar_rev_id...\n" ); - $dbw = $this->getDB( DB_MASTER ); + // Sanity check. If this is a new install, we don't need to do anything here. + if ( PopulateArchiveRevId::isNewInstall( $dbw ) ) { + $this->output( "New install, nothing to do here.\n" ); + return true; + } + PopulateArchiveRevId::checkMysqlAutoIncrementBug( $dbw ); $minId = $dbw->selectField( 'archive', 'MIN(ar_rev_id)', [], __METHOD__ ); diff --git a/maintenance/populateArchiveRevId.php b/maintenance/populateArchiveRevId.php index 96fcebf409..c85e194eef 100644 --- a/maintenance/populateArchiveRevId.php +++ b/maintenance/populateArchiveRevId.php @@ -43,6 +43,15 @@ class PopulateArchiveRevId extends LoggedUpdateMaintenance { $this->setBatchSize( 100 ); } + /** + * @param IDatabase $dbw + * @return bool + */ + public static function isNewInstall( IDatabase $dbw ) { + return $dbw->selectRowCount( 'archive' ) === 0 && + $dbw->selectRowCount( 'revision' ) === 1; + } + protected function getUpdateKey() { return __CLASS__; }