maintenance/populateChangeTagDef.php: Handle missing valid_tags table
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 14 Aug 2019 15:57:12 +0000 (11:57 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 14 Aug 2019 15:57:12 +0000 (11:57 -0400)
The valid_tags table was added in MW 1.15 and removed in 1.33. If
someone is trying to upgrade from a really old version of MediaWiki,
valid_tags may not exist even though change_tags.ct_tag does.

Bug: T230317
Change-Id: Ib94542878b8d301c1d7f806405ee39838ebc6d4a

maintenance/populateChangeTagDef.php

index 6c46597..2be690b 100644 (file)
@@ -74,12 +74,15 @@ class PopulateChangeTagDef extends LoggedUpdateMaintenance {
        private function setUserDefinedTags() {
                $dbr = $this->lbFactory->getMainLB()->getConnection( DB_REPLICA );
 
-               $userTags = $dbr->selectFieldValues(
-                       'valid_tag',
-                       'vt_tag',
-                       [],
-                       __METHOD__
-               );
+               $userTags = null;
+               if ( $dbr->tableExists( 'valid_tag' ) ) {
+                       $userTags = $dbr->selectFieldValues(
+                               'valid_tag',
+                               'vt_tag',
+                               [],
+                               __METHOD__
+                       );
+               }
 
                if ( empty( $userTags ) ) {
                        $this->output( "No user defined tags to set, moving on...\n" );