26require_once __DIR__ .
'/Maintenance.php';
36 parent::__construct();
46 $this->
output(
"Populating ar_rev_id...\n" );
50 $any = $dbw->selectField(
53 [
'ar_rev_id' =>
null ],
57 $this->
output(
"Completed ar_rev_id population, 0 rows updated.\n" );
66 $arIds = $dbw->selectFieldValues(
69 [
'ar_rev_id' =>
null ],
71 [
'LIMIT' => $this->
getBatchSize(),
'ORDER BY' => [
'ar_id' ] ]
74 $this->
output(
"Completed ar_rev_id population, $count rows updated.\n" );
79 $updates = $dbw->doAtomicSection( __METHOD__,
function ( $dbw,
$fname ) use ( $arIds,
$rev ) {
81 $dbw->insert(
'revision', array_fill( 0, count( $arIds ),
$rev ),
$fname );
82 $revIds = $dbw->selectFieldValues(
85 [
'rev_timestamp' =>
$rev[
'rev_timestamp'] ],
88 if ( !is_array( $revIds ) ) {
89 throw new UnexpectedValueException(
'Failed to insert dummy revisions' );
91 if ( count( $revIds ) !== count( $arIds ) ) {
92 throw new UnexpectedValueException(
93 'Tried to insert ' . count( $arIds ) .
' dummy revisions, but found '
94 . count( $revIds ) .
' matching rows.'
97 $dbw->delete(
'revision', [
'rev_id' => $revIds ],
$fname );
99 return array_combine( $arIds, $revIds );
101 }
catch ( UnexpectedValueException $ex ) {
105 foreach ( $updates as $arId => $revId ) {
108 [
'ar_rev_id' => $revId ],
109 [
'ar_id' => $arId,
'ar_rev_id' =>
null ],
112 $count += $dbw->affectedRows();
115 $min = min( array_keys( $updates ) );
116 $max = max( array_keys( $updates ) );
117 $this->
output(
" ... $min-$max\n" );
132 $ts = $dbw->
timestamp(
'11111111111111' );
133 $mainPage = Title::newMainPage();
135 $this->
fatalError(
'Main page does not exist' );
137 $pageId = $mainPage->getArticleId();
139 $this->
fatalError( $mainPage->getPrefixedText() .
' has no ID' );
144 [
'rev_page' => $pageId ],
146 [
'ORDER BY' =>
'rev_timestamp ASC' ]
149 $this->
fatalError( $mainPage->getPrefixedText() .
' has no revisions' );
151 unset(
$rev->rev_id );
153 $rev[
'rev_timestamp'] = $ts;
154 if ( isset(
$rev[
'rev_user'] ) ) {
155 $rev[
'rev_user'] = 0;
156 $rev[
'rev_user_text'] =
'0.0.0.0';
158 if ( isset(
$rev[
'rev_comment'] ) ) {
159 $rev[
'rev_comment'] =
'Dummy row';
165 [
'rev_timestamp' => $ts ],
169 $this->
fatalError(
"... 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.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
setBatchSize( $s=0)
Set the batch size.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
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.
makeDummyRevisionRow(IDatabase $dbw)
Construct a dummy revision table row to use for reserving IDs.
__construct()
Default constructor.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
the array() calling protocol came about after MediaWiki 1.4rc1.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
require_once RUN_MAINTENANCE_IF_MAIN