Mattflaschen has uploaded a new change for review. https://gerrit.wikimedia.org/r/206956
Change subject: Create missing board pages ...................................................................... Create missing board pages Bug: T95594 Change-Id: I67ac1bc3def5cce143b7b08b5d4301fe741df09b (cherry picked from commit 4dd12e25cb96a651704dc6327df42c73c2daad7e) --- M maintenance/FlowUpdateWorkflowPageId.php 1 file changed, 26 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/56/206956/1 diff --git a/maintenance/FlowUpdateWorkflowPageId.php b/maintenance/FlowUpdateWorkflowPageId.php index 5056ecd..a4a61ac 100644 --- a/maintenance/FlowUpdateWorkflowPageId.php +++ b/maintenance/FlowUpdateWorkflowPageId.php @@ -2,6 +2,7 @@ use Flow\Container; use Flow\Model\UUID; +use Flow\OccupationController; $IP = getenv( 'MW_INSTALL_PATH' ); if ( $IP === false ) { @@ -43,7 +44,6 @@ 'workflow_wiki' => wfWikiId(), 'workflow_page_id' => 0, ) ); - $gen = new WorkflowPageIdUpdateGenerator( $wgLang ); $writer = new EchoBatchRowWriter( $dbw, 'flow_workflow', $wgFlowCluster ); @@ -87,7 +87,31 @@ ) ); } - if ( $title->getArticleID() !== (int)$row->workflow_page_id ) { + // title doesn't exist, so create it + if ( $title->getArticleID() === 0 ) { + // build workflow object (yes, loading them piecemeal is suboptimal, but + // this is just a one-time script; considering the alternative is + // creating a derivative EchoBatchRowIterator that returns workflows, + // it doesn't really matter) + $storage = Container::get( 'storage' ); + $workflow = $storage->get( 'Workflow', UUID::create( $row->workflow_id ) ); + + try { + /** @var OccupationController $occupationController */ + $occupationController = Container::get( 'occupation_controller' ); + $occupationController->allowCreation( $title, $occupationController->getTalkpageManager() ); + $occupationController->ensureFlowRevision( new Article( $title ), $workflow ); + + // force article id to be refetched from db + $title->getArticleID( Title::GAID_FOR_UPDATE ); + } catch ( \Exception $e ) { + // catch all exception to keep going with the rest we want to + // iterate over, we'll report on the failed entries at the end + $this->failed[] = $row; + } + } + + if ( $title->getArticleID() !== (int) $row->workflow_page_id ) { // This makes the assumption the page has not moved or been deleted? ++$this->fixedCount; return array( -- To view, visit https://gerrit.wikimedia.org/r/206956 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I67ac1bc3def5cce143b7b08b5d4301fe741df09b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: wmf/1.26wmf2 Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits