jenkins-bot has submitted this change and it was merged. Change subject: Add script to populate rev_content_model for $wgFlowOccupyPages ......................................................................
Add script to populate rev_content_model for $wgFlowOccupyPages This should be deployed and run as the first step of T105574. No pages can be occupied using $wgFlowOccupyPages after it is run (we haven't been adding them for a while this way anyway). Bug: T105574 Change-Id: Ida772d1299f9b03aae1ebe0f4f0237d781eb4377 --- A maintenance/FlowUpdateRevContentModelFromOccupyPages.php 1 file changed, 75 insertions(+), 0 deletions(-) Approvals: Matthias Mullie: Looks good to me, approved jenkins-bot: Verified diff --git a/maintenance/FlowUpdateRevContentModelFromOccupyPages.php b/maintenance/FlowUpdateRevContentModelFromOccupyPages.php new file mode 100644 index 0000000..b26de04 --- /dev/null +++ b/maintenance/FlowUpdateRevContentModelFromOccupyPages.php @@ -0,0 +1,75 @@ +<?php + +require_once ( getenv( 'MW_INSTALL_PATH' ) !== false + ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php' + : dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' ); + +/** + * This script should be run immediately before dropping the wgFlowOccupyPages + * configuration variable, to ensure that rev_content_model is set appropriately. + * + * See comments at https://gerrit.wikimedia.org/r/#/c/228267/ . + * + * It sets rev_content_model to flow-board for the last revision of all occupied pages. + * + * @ingroup Maintenance + */ +class FlowUpdateRevContentModelFromOccupyPages extends Maintenance { + public function __construct() { + parent::__construct(); + + $this->mDescription = 'Sets rev_content_model from wgFlowOccupyPages, in preparation for dropping that config variable.'; + + // Given the number of occupied pages, this probably doesn't need to be + // batched; just being cautious. + $this->setBatchSize( 10 ); + } + + public function execute() { + global $wgFlowOccupyPages; + + $dbw = wfGetDB( DB_MASTER ); + + $pageCount = count( $wgFlowOccupyPages ); + $overallInd = 0; + $updatedCount = 0; + $skippedCount = 0; + + while ( $overallInd < $pageCount ) { + $dbw->begin(); + $batchInd = 0; + while( $overallInd < $pageCount && $batchInd < $this->mBatchSize ) { + $pageName = $wgFlowOccupyPages[$overallInd]; + $title = Title::newFromTextThrow( $pageName ); + $revId = $title->getLatestRevID( Title::GAID_FOR_UPDATE ); + if ( $revId !== 0 ) { + $dbw->update( + 'revision', + array( + 'rev_content_model' => + CONTENT_MODEL_FLOW_BOARD + ), + array( 'rev_id' => $revId ), + __METHOD__ + ); + $updatedCount++; + $this->output( "Set content model for \"{$title->getPrefixedDBkey()}\"\n" ); + } else { + $skippedCount++; + $this->output( "WARNING: Skipped \"{$title->getPrefixedDBkey()}\" because it does not exist\n" ); + } + + $overallInd++; + $batchInd++; + } + + $dbw->commit(); + $this->output( "Completed batch.\n\n" ); + } + + $this->output( "Set content model for $updatedCount pages; skipped $skippedCount pages.\n" ); + } +} + +$maintClass = 'FlowUpdateRevContentModelFromOccupyPages'; +require_once( RUN_MAINTENANCE_IF_MAIN ); -- To view, visit https://gerrit.wikimedia.org/r/230370 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ida772d1299f9b03aae1ebe0f4f0237d781eb4377 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Mattflaschen <[email protected]> Gerrit-Reviewer: Legoktm <[email protected]> Gerrit-Reviewer: Matthias Mullie <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
