28 require_once __DIR__ .
'/Maintenance.php';
38 parent::__construct();
40 'Fix instances of JSON pages prior to them being the ContentHandler default' );
54 foreach ( $namespaces as $ns => $like ) {
59 [
'page_id',
'page_title',
'page_namespace',
'page_content_model' ],
61 'page_namespace' => $ns,
62 'page_title ' . $like,
63 'page_id > ' .
$dbr->addQuotes( $lastPage )
66 [
'ORDER BY' =>
'page_id',
'LIMIT' => $this->getBatchSize() ]
68 foreach ( $rows as $row ) {
70 $lastPage = $row->page_id;
72 }
while ( $rows->numRows() >= $this->getBatchSize() );
80 $this->
output(
"Processing {$title} ({$row->page_id})...\n" );
81 $rev = MediaWikiServices::getInstance()
83 ->getRevisionByTitle(
$title );
84 $content = $rev->getContent( SlotRecord::MAIN, RevisionRecord::RAW );
87 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
92 $this->
output(
"Setting page_content_model to json..." );
96 [
'page_id' => $row->page_id ],
99 $this->
output(
"done.\n" );
100 $lbFactory->waitForReplication();
106 $this->
output(
"Setting rev_content_model to wikitext..." );
108 $ids = $dbw->selectFieldValues(
111 [
'rev_page' => $row->page_id ],
114 foreach ( array_chunk( $ids, 50 ) as $chunk ) {
118 [
'rev_page' => $row->page_id,
'rev_id' => $chunk ],
121 $lbFactory->waitForReplication();
123 $this->
output(
"done.\n" );
126 $this->
output(
"not a JSON page? Skipping\n" );
132 require_once RUN_MAINTENANCE_IF_MAIN;
const CONTENT_MODEL_WIKITEXT
Usage: fixDefaultJsonContentPages.php.
getUpdateKey()
Get the update key name to go in the update log table.
__construct()
Default constructor.
doDBUpdates()
Do the actual work.
JSON text content that can be viewed and edit directly by users.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.