Go to the documentation of this file.
24 require_once __DIR__ .
'/Maintenance.php';
34 parent::__construct();
36 'Migrates content from pre-1.5 ar_text and ar_flags columns to text storage'
40 "For rows with missing or unloadable data, throw away whatever is there and\n"
41 .
"mark them as \"error\" in the database."
50 $this->mOptions[
'force'] = $forced;
60 $replaceMissing = $this->
hasOption(
'replace-missing' );
65 if ( !
$dbr->fieldExists(
'archive',
'ar_text', __METHOD__ ) ||
66 !$dbw->fieldExists(
'archive',
'ar_text', __METHOD__ )
68 $this->
output(
"No ar_text field, so nothing to migrate.\n" );
72 $this->
output(
"Migrating ar_text to modern storage...\n" );
79 [
'ar_id',
'ar_text',
'ar_flags' ],
85 [
'LIMIT' => $batchSize,
'ORDER BY' => [
'ar_id' ] ]
87 $numRows =
$res->numRows();
94 if ( !in_array(
'external', explode(
',', $row->ar_flags ),
true ) ) {
96 if ( $data !==
false ) {
102 throw new MWException(
"Unable to store text to external storage" );
107 $flags .=
'external';
109 } elseif ( $replaceMissing ) {
110 $this->
error(
"Replacing missing data for row ar_id=$row->ar_id" );
111 $data =
'Missing data in migrateArchiveText.php on ' . date(
'c' );
114 $this->
error(
"No data for row ar_id=$row->ar_id" );
119 $flags = $row->ar_flags;
120 $data = $row->ar_text;
126 [
'old_text' => $data,
'old_flags' => $flags ],
129 $id = $dbw->insertId();
132 [
'ar_text_id' => $id,
'ar_text' =>
'',
'ar_flags' =>
'' ],
133 [
'ar_id' => $row->ar_id,
'ar_text_id' =>
null ],
136 $count += $dbw->affectedRows();
140 if ( $numRows < $batchSize ) {
145 $this->
output(
"... $last\n" );
149 $this->
output(
"Completed ar_text migration, $count rows updated, $errors missing data.\n" );
151 $this->
output(
"Run with --replace-missing to overwrite missing data with an error message.\n" );
154 return $errors === 0;
static insertToDefault( $data, array $params=[])
Like insert() above, but does more of the work for us.
__construct()
Default constructor.
addDescription( $text)
Set the description text.
require_once RUN_MAINTENANCE_IF_MAIN
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
Maintenance script that migrates archive.ar_text and ar_flags to text storage.
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
getUpdateKey()
Get the update key name to go in the update log table.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
setForce( $forced=true)
Sets whether a run of this maintenance script has the force parameter set.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
getBatchSize()
Returns batch size.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
hasOption( $name)
Checks to see if a particular option exists.
doDBUpdates()
Do the actual work.