From: jenkins-bot Date: Wed, 12 Sep 2018 19:32:00 +0000 (+0000) Subject: Merge "Add part to update ctd_user_defined in populateChangeTagDef" X-Git-Tag: 1.34.0-rc.0~4106 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=01cdb1762c7207bd261ad03726a88cb9afc97bfb;hp=ef7be3e36afe1aca1bece181e95f7d8b47760dee Merge "Add part to update ctd_user_defined in populateChangeTagDef" --- diff --git a/maintenance/populateChangeTagDef.php b/maintenance/populateChangeTagDef.php index b11b95fd72..7bec25ac97 100644 --- a/maintenance/populateChangeTagDef.php +++ b/maintenance/populateChangeTagDef.php @@ -39,6 +39,7 @@ class PopulateChangeTagDef extends LoggedUpdateMaintenance { true ); $this->addOption( 'populate-only', 'Do not update change_tag_def table' ); + $this->addOption( 'set-user-tags-only', 'Only update ctd_user_defined from valid_tag table' ); } public function execute() { @@ -61,10 +62,15 @@ class PopulateChangeTagDef extends LoggedUpdateMaintenance { __METHOD__ ) ) { + if ( $this->hasOption( 'set-user-tags-only' ) ) { + $this->setUserDefinedTags(); + return true; + } if ( !$this->hasOption( 'populate-only' ) ) { $this->updateCountTag(); } $this->backpopulateChangeTagId(); + $this->setUserDefinedTags(); } else { $this->updateCountTagId(); } @@ -75,6 +81,40 @@ class PopulateChangeTagDef extends LoggedUpdateMaintenance { return true; } + private function setUserDefinedTags() { + $dbr = $this->lbFactory->getMainLB()->getConnection( DB_REPLICA ); + + $userTags = $dbr->selectFieldValues( + 'valid_tag', + 'vt_tag', + [], + __METHOD__ + ); + + if ( empty( $userTags ) ) { + $this->output( "No user defined tags to set, moving on...\n" ); + return; + } + + if ( $this->hasOption( 'dry-run' ) ) { + $this->output( + 'These tags will have ctd_user_defined=1 : ' . implode( ', ', $userTags ) . "\n" + ); + return; + } + + $dbw = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); + + $dbw->update( + 'change_tag_def', + [ 'ctd_user_defined' => 1 ], + [ 'ctd_name' => $userTags ], + __METHOD__ + ); + $this->lbFactory->waitForReplication(); + $this->output( "Finished setting user defined tags in change_tag_def table\n" ); + } + private function updateCountTagId() { $dbr = $this->lbFactory->getMainLB()->getConnection( DB_REPLICA );