class FixDefaultJsonContentPages extends LoggedUpdateMaintenance {
public function __construct() {
parent::__construct();
- $this->mDescription =
- 'Fix instances of JSON pages prior to them being the ContentHandler default';
+ $this->addDescription(
+ 'Fix instances of JSON pages prior to them being the ContentHandler default' );
$this->setBatchSize( 100 );
}
return true;
}
- $dbr = $this->getDB( DB_SLAVE );
- $namespaces = array(
+ $dbr = $this->getDB( DB_REPLICA );
+ $namespaces = [
NS_MEDIAWIKI => $dbr->buildLike( $dbr->anyString(), '.json' ),
NS_USER => $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString(), '.json' ),
- );
+ ];
foreach ( $namespaces as $ns => $like ) {
$lastPage = 0;
do {
$rows = $dbr->select(
'page',
- array( 'page_id', 'page_title', 'page_namespace', 'page_content_model' ),
- array(
+ [ 'page_id', 'page_title', 'page_namespace', 'page_content_model' ],
+ [
'page_namespace' => $ns,
'page_title ' . $like,
'page_id > ' . $dbr->addQuotes( $lastPage )
- ),
+ ],
__METHOD__,
- array( 'ORDER BY' => 'page_id', 'LIMIT' => $this->mBatchSize )
+ [ 'ORDER BY' => 'page_id', 'LIMIT' => $this->mBatchSize ]
);
foreach ( $rows as $row ) {
$this->handleRow( $row );
$this->output( "Setting page_content_model to json..." );
$dbw->update(
'page',
- array( 'page_content_model' => CONTENT_MODEL_JSON ),
- array( 'page_id' => $row->page_id ),
+ [ 'page_content_model' => CONTENT_MODEL_JSON ],
+ [ 'page_id' => $row->page_id ],
__METHOD__
);
$this->output( "done.\n" );
$ids = $dbw->selectFieldValues(
'revision',
'rev_id',
- array( 'rev_page' => $row->page_id ),
+ [ 'rev_page' => $row->page_id ],
__METHOD__
);
foreach ( array_chunk( $ids, 50 ) as $chunk ) {
$dbw->update(
'revision',
- array( 'rev_content_model' => CONTENT_MODEL_WIKITEXT ),
- array( 'rev_page' => $row->page_id, 'rev_id' => $chunk )
+ [ 'rev_content_model' => CONTENT_MODEL_WIKITEXT ],
+ [ 'rev_page' => $row->page_id, 'rev_id' => $chunk ]
);
wfWaitForSlaves();
}