mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 16:04:35 +00:00
99377e5525
This script was supposed to be run in production in 2013, but that never happened. It was also never added to update.php. * Use makeTitleSafe instead of newFromText, for correctness * Fetch the columns that the update generator needs * Replace wrapper for private method with closure * Make the maintenance script logged Bug: T136427 Bug: T50059 Change-Id: I6c2972120189f035483b5ca49610c008c4ba2c88
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Update event_page_id in echo_event based on event_page_title and
|
|
* event_page_namespace
|
|
*
|
|
* @ingroup Maintenance
|
|
*/
|
|
require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
|
|
? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
|
|
: __DIR__ . '/../../../maintenance/Maintenance.php' );
|
|
|
|
/**
|
|
* Maintenance script that populates the event_page_id column of echo_event
|
|
*
|
|
* @ingroup Maintenance
|
|
*/
|
|
class UpdateEchoSchemaForSuppression extends LoggedUpdateMaintenance {
|
|
|
|
/**
|
|
* @var string The table to update
|
|
*/
|
|
protected $table = 'echo_event';
|
|
|
|
/**
|
|
* @var string The primary key column of the table to update
|
|
*/
|
|
protected $idField = 'event_id';
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->setBatchSize( 500 );
|
|
}
|
|
|
|
public function getUpdateKey() {
|
|
return __CLASS__;
|
|
}
|
|
|
|
public function doDBUpdates() {
|
|
global $wgEchoCluster;
|
|
|
|
$reader = new BatchRowIterator( MWEchoDbFactory::getDB( DB_SLAVE ), $this->table, $this->idField, $this->mBatchSize );
|
|
$reader->addConditions( array(
|
|
"event_page_title IS NOT NULL",
|
|
"event_page_id" => null,
|
|
) );
|
|
$reader->setFetchColumns( array( 'event_page_namespace', 'event_page_title', 'event_extra', 'event_type' ) );
|
|
|
|
$updater = new BatchRowUpdate(
|
|
$reader,
|
|
new BatchRowWriter( MWEchoDbFactory::getDB( DB_MASTER ), $this->table, $wgEchoCluster ),
|
|
new EchoSuppressionRowUpdateGenerator
|
|
);
|
|
$updater->setOutput( function ( $text ) {
|
|
$this->output( $text );
|
|
} );
|
|
$updater->execute();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
$maintClass = 'UpdateEchoSchemaForSuppression'; // Tells it to run the class
|
|
require_once ( RUN_MAINTENANCE_IF_MAIN );
|