27require_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' );
209 $mainPage = Title::newMainPage();
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" );
239 $title = Title::newFromText(
"PopulateArchiveRevId_4b05b46a81e29" );
240 $page = WikiPage::factory(
$title );
241 $updater = $page->newPageUpdater(
244 $updater->setContent(
246 ContentHandler::makeContent(
"Content for dummy rev",
$title )
248 $updater->saveRevision(
249 CommentStoreComment::newUnsavedComment(
'dummy rev summary' ),
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?" );
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
const RUN_MAINTENANCE_IF_MAIN
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
output( $out, $channel=null)
Throw some output to the user.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
setBatchSize( $s=0)
Set the batch size.
Maintenance script that populares archive.ar_rev_id in old rows.
doDBUpdates()
Do the actual work.
getUpdateKey()
Get the update key name to go in the update log table.
static array null $dummyRev
Dummy revision row.
static checkMysqlAutoIncrementBug(IDatabase $dbw)
Check for (and work around) a MySQL auto-increment bug.
static reassignArRevIds(IDatabase $dbw, array $arIds, array $conds=[])
Assign new ar_rev_ids to a set of ar_ids.
static makeDummyRevisionRow(IDatabase $dbw)
Construct a dummy revision table row to use for reserving IDs.
static isNewInstall(IDatabase $dbw)
__construct()
Default constructor.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.