2013-05-09 18:50:05 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Update event_page_id in echo_event based on event_page_title and
|
|
|
|
* event_page_namespace
|
|
|
|
*
|
|
|
|
* @ingroup Maintenance
|
|
|
|
*/
|
2015-10-29 11:16:49 +00:00
|
|
|
require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
|
2013-05-09 18:50:05 +00:00
|
|
|
? 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
|
|
|
|
*/
|
2016-06-06 21:02:03 +00:00
|
|
|
class UpdateEchoSchemaForSuppression extends LoggedUpdateMaintenance {
|
2013-05-09 18:50:05 +00:00
|
|
|
|
|
|
|
/**
|
2015-12-14 10:03:09 +00:00
|
|
|
* @var string The table to update
|
2013-05-09 18:50:05 +00:00
|
|
|
*/
|
|
|
|
protected $table = 'echo_event';
|
|
|
|
|
|
|
|
/**
|
2015-12-14 10:03:09 +00:00
|
|
|
* @var string The primary key column of the table to update
|
2013-05-09 18:50:05 +00:00
|
|
|
*/
|
|
|
|
protected $idField = 'event_id';
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->setBatchSize( 500 );
|
|
|
|
}
|
|
|
|
|
2016-06-06 21:02:03 +00:00
|
|
|
public function getUpdateKey() {
|
|
|
|
return __CLASS__;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function doDBUpdates() {
|
2013-05-09 18:50:05 +00:00
|
|
|
global $wgEchoCluster;
|
|
|
|
|
2015-12-15 21:33:41 +00:00
|
|
|
$reader = new BatchRowIterator( MWEchoDbFactory::getDB( DB_SLAVE ), $this->table, $this->idField, $this->mBatchSize );
|
2013-05-09 18:50:05 +00:00
|
|
|
$reader->addConditions( array(
|
|
|
|
"event_page_title IS NOT NULL",
|
|
|
|
"event_page_id" => null,
|
|
|
|
) );
|
2016-06-06 21:02:03 +00:00
|
|
|
$reader->setFetchColumns( array( 'event_page_namespace', 'event_page_title', 'event_extra', 'event_type' ) );
|
2013-05-09 18:50:05 +00:00
|
|
|
|
2015-12-15 21:33:41 +00:00
|
|
|
$updater = new BatchRowUpdate(
|
2013-05-09 18:50:05 +00:00
|
|
|
$reader,
|
2015-12-15 21:33:41 +00:00
|
|
|
new BatchRowWriter( MWEchoDbFactory::getDB( DB_MASTER ), $this->table, $wgEchoCluster ),
|
2013-05-09 18:50:05 +00:00
|
|
|
new EchoSuppressionRowUpdateGenerator
|
|
|
|
);
|
2016-06-06 21:02:03 +00:00
|
|
|
$updater->setOutput( function ( $text ) {
|
|
|
|
$this->output( $text );
|
|
|
|
} );
|
2013-05-09 18:50:05 +00:00
|
|
|
$updater->execute();
|
2016-06-06 21:02:03 +00:00
|
|
|
return true;
|
2013-05-09 18:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = 'UpdateEchoSchemaForSuppression'; // Tells it to run the class
|
2015-10-29 11:16:49 +00:00
|
|
|
require_once ( RUN_MAINTENANCE_IF_MAIN );
|