X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateArchiveRevId.php;h=c03eb24853090fb089fbe52913b233aeb8c6cb85;hb=cba0fb1c1576324e87b27b6d31ee4359195025c8;hp=60f5e8a12611cf07de699fa080597d902aa13857;hpb=74d04edec385aa86ee01943b9a27475d79f74e78;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateArchiveRevId.php b/maintenance/populateArchiveRevId.php index 60f5e8a126..c03eb24853 100644 --- a/maintenance/populateArchiveRevId.php +++ b/maintenance/populateArchiveRevId.php @@ -220,7 +220,43 @@ class PopulateArchiveRevId extends LoggedUpdateMaintenance { ); } if ( !$rev ) { - throw new UnexpectedValueException( 'No revisions are available to copy' ); + // Since no revisions are available to copy, generate a dummy + // revision to a dummy page, then rollback the commit + wfDebug( __METHOD__ . ": No revisions are available to copy\n" ); + + $dbw->begin(); + + // Make a title and revision and insert them + $title = Title::newFromText( "PopulateArchiveRevId_4b05b46a81e29" ); + $page = WikiPage::factory( $title ); + $updater = $page->newPageUpdater( + User::newSystemUser( 'Maintenance script', [ 'steal' => true ] ) + ); + $updater->setContent( + 'main', + ContentHandler::makeContent( "Content for dummy rev", $title ) + ); + $updater->saveRevision( + CommentStoreComment::newUnsavedComment( 'dummy rev summary' ), + EDIT_NEW | EDIT_SUPPRESS_RC + ); + + // get the revision row just inserted + $rev = $dbw->selectRow( + 'revision', + '*', + [], + __METHOD__, + [ 'ORDER BY' => 'rev_timestamp ASC' ] + ); + + $dbw->rollback(); + } + if ( !$rev ) { + // This should never happen. + throw new UnexpectedValueException( + 'No revisions are available to copy, and one couldn\'t be created' + ); } unset( $rev->rev_id );