Go to the documentation of this file.
27 require_once __DIR__ .
'/Maintenance.php';
41 parent::__construct();
60 $this->
output(
"Populating ar_rev_id...\n" );
65 $any = $dbw->selectField(
68 [
'ar_rev_id' =>
null ],
72 $this->
output(
"Completed ar_rev_id population, 0 rows updated.\n" );
80 $arIds = $dbw->selectFieldValues(
83 [
'ar_rev_id' =>
null ],
85 [
'LIMIT' => $this->
getBatchSize(),
'ORDER BY' => [
'ar_id' ] ]
88 $this->
output(
"Completed ar_rev_id population, $count rows updated.\n" );
96 $this->
output(
" ... $min-$max\n" );
111 if ( $dbw->
getType() !==
'mysql' ) {
115 if ( !self::$dummyRev ) {
123 $dbw->
insert(
'revision', self::$dummyRev, $fname );
128 (
int)$dbw->
selectField(
'archive',
'MAX(ar_rev_id)', [], $fname ),
129 (int)$dbw->
selectField(
'slots',
'MAX(slot_revision_id)', [], $fname )
131 if ( $id <= $maxId ) {
132 $dbw->
insert(
'revision', [
'rev_id' => $maxId + 1 ] + self::$dummyRev, $fname );
133 $toDelete[] = $maxId + 1;
136 $dbw->
delete(
'revision', [
'rev_id' => $toDelete ], $fname );
140 if ( $e->errno != 1062 ) {
155 if ( !self::$dummyRev ) {
161 $dbw->
insert(
'revision', array_fill( 0, count( $arIds ), self::$dummyRev ), $fname );
165 [
'rev_timestamp' => self::$dummyRev[
'rev_timestamp'] ],
168 if ( !is_array( $revIds ) ) {
169 throw new UnexpectedValueException(
'Failed to insert dummy revisions' );
171 if ( count( $revIds ) !== count( $arIds ) ) {
172 throw new UnexpectedValueException(
173 'Tried to insert ' . count( $arIds ) .
' dummy revisions, but found '
174 . count( $revIds ) .
' matching rows.'
177 $dbw->
delete(
'revision', [
'rev_id' => $revIds ], $fname );
179 return array_combine( $arIds, $revIds );
183 foreach ( $updates as $arId => $revId ) {
186 [
'ar_rev_id' => $revId ],
187 [
'ar_id' => $arId ] + $conds,
206 $ts = $dbw->
timestamp(
'11111111111111' );
210 $pageId = $mainPage ? $mainPage->getArticleID() :
null;
215 [
'rev_page' => $pageId ],
217 [
'ORDER BY' =>
'rev_timestamp ASC' ]
228 [
'ORDER BY' =>
'rev_timestamp ASC' ]
234 wfDebug( __METHOD__ .
": No revisions are available to copy\n" );
241 $updater = $page->newPageUpdater(
244 $updater->setContent(
248 $updater->saveRevision(
259 [
'ORDER BY' =>
'rev_timestamp ASC' ]
266 throw new UnexpectedValueException(
267 'No revisions are available to copy, and one couldn\'t be created'
271 unset( $rev->rev_id );
273 $rev[
'rev_timestamp'] = $ts;
274 if ( isset( $rev[
'rev_user'] ) ) {
275 $rev[
'rev_user'] = 0;
276 $rev[
'rev_user_text'] =
'0.0.0.0';
278 if ( isset( $rev[
'rev_comment'] ) ) {
279 $rev[
'rev_comment'] =
'Dummy row';
285 [
'rev_timestamp' => $ts ],
289 throw new UnexpectedValueException(
"... Why does your database contain a revision dated $ts?" );
const RUN_MAINTENANCE_IF_MAIN
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static makeDummyRevisionRow(IDatabase $dbw)
Construct a dummy revision table row to use for reserving IDs.
static array null $dummyRev
Dummy revision row.
addDescription( $text)
Set the description text.
static newMainPage(MessageLocalizer $localizer=null)
Create a new Title for the Main Page.
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
__construct()
Default constructor.
static checkMysqlAutoIncrementBug(IDatabase $dbw)
Check for (and work around) a MySQL auto-increment bug.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
Maintenance script that populares archive.ar_rev_id in old rows.
doDBUpdates()
Do the actual work.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static reassignArRevIds(IDatabase $dbw, array $arIds, array $conds=[])
Assign new ar_rev_ids to a set of ar_ids.
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
getBatchSize()
Returns batch size.
static isNewInstall(IDatabase $dbw)
output( $out, $channel=null)
Throw some output to the user.
getUpdateKey()
Get the update key name to go in the update log table.
setBatchSize( $s=0)
Set the batch size.