Bsitu has uploaded a new change for review. https://gerrit.wikimedia.org/r/134985
Change subject: [WIP]Update flow_revision_state ...................................................................... [WIP]Update flow_revision_state DON'T REVIEW, this is a very initial draft Change-Id: I89a4d8ba5ac23c1bcfba24b54fea30c914daae12 --- M Hooks.php A maintenance/FlowUpdateRevisionState.php 2 files changed, 89 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/85/134985/1 diff --git a/Hooks.php b/Hooks.php index 404d489..33308ed 100644 --- a/Hooks.php +++ b/Hooks.php @@ -143,6 +143,9 @@ require_once __DIR__.'/maintenance/FlowUpdateRevisionTypeId.php'; $updater->addPostDatabaseUpdateMaintenance( 'FlowUpdateRevisionTypeId' ); + require_once __DIR__.'/maintenance/FlowUpdateRevisionState.php'; + $updater->addPostDatabaseUpdateMaintenance( 'FlowUpdateRevisionState' ); + require_once __DIR__.'/maintenance/FlowPopulateLinksTables.php'; $updater->addPostDatabaseUpdateMaintenance( 'FlowPopulateLinksTables' ); diff --git a/maintenance/FlowUpdateRevisionState.php b/maintenance/FlowUpdateRevisionState.php new file mode 100644 index 0000000..91b1d10 --- /dev/null +++ b/maintenance/FlowUpdateRevisionState.php @@ -0,0 +1,86 @@ +<?php + +use Flow\Container; + +$IP = getenv( 'MW_INSTALL_PATH' ); +if ( $IP === false ) { + $IP = __DIR__ . '/../../..'; +} +require_once( "$IP/maintenance/Maintenance.php" ); + +/** + * Update flow_revision_state + * + * @ingroup Maintenance + */ +class FlowUpdateRevisionState extends LoggedUpdateMaintenance { + + public function __construct() { + parent::__construct(); + $this->mDescription = "Update flow_revision_state"; + $this->setBatchSize( 300 ); + } + + protected function doDBUpdates() { + $revId = ''; + $count = $this->mBatchSize; + $dbFactory = Container::get( 'db.factory' ); + $dbr = $dbFactory->getDB( DB_SLAVE ); + $dbw = $dbFactory->getDB( DB_MASTER ); + + while ( $count == $this->mBatchSize ) { + $count = 0; + $res = $dbr->select( + array( 'flow_revision' ), + array( + 'frs_rev_id' => 'rev_id', + 'frs_state' => 'rev_mod_state', + 'frs_user_id' => 'rev_mod_user_id', + 'frs_user_ip' => 'rev_mod_user_ip', + 'frs_user_wiki' => 'rev_mod_user_wiki', + 'frs_comment' => 'rev_mod_reason' + ), + array( 'rev_id > ' . $dbr->addQuotes( $revId ) ), + __METHOD__, + array( 'ORDER BY' => 'rev_id ASC', 'LIMIT' => $this->mBatchSize ) + ); + + if ( $res ) { + foreach ( $res as $row ) { + $count++; + $revId = $row->frs_rev_id; + $this->insertRevisionState( $dbw, $row ); + } + } else { + throw new MWException( 'SQL error in maintenance script ' . __CLASS__ . '::' . __METHOD__ ); + } + $dbFactory->waitForSlaves(); + } + + return true; + } + + private function insertRevisionState( $dbw, $row ) { + $res = $dbw->insert( + 'flow_revision_state', + $insert, + __METHOD__, + array( 'IGNORE' ) + ); + if ( !$res ) { + throw new MWException( 'SQL error in maintenance script ' . __CLASS__ . '::' . __METHOD__ ); + } + } + + /** + * Get the update key name to go in the update log table + * + * @return string + */ + protected function getUpdateKey() { + return 'FlowUpdateRevisionState'; + } +} + +$maintClass = 'FlowUpdateRevisionState'; +require_once( DO_MAINTENANCE ); -- To view, visit https://gerrit.wikimedia.org/r/134985 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I89a4d8ba5ac23c1bcfba24b54fea30c914daae12 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Bsitu <bs...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits