2013-01-15 23:21:39 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Remove invalid events from echo_event and echo_notification
|
|
|
|
*
|
|
|
|
* @ingroup Maintenance
|
|
|
|
*/
|
2015-10-01 13:48:52 +00:00
|
|
|
require_once( getenv( 'MW_INSTALL_PATH' ) !== false
|
2013-01-15 23:21:39 +00:00
|
|
|
? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
|
|
|
|
: dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maintenance script that removes invalid notifications
|
|
|
|
*
|
|
|
|
* @ingroup Maintenance
|
|
|
|
*/
|
|
|
|
class removeInvalidNotification extends Maintenance {
|
|
|
|
|
|
|
|
protected $batchSize = 500;
|
|
|
|
protected $invalidEventType = array( 'article-linked' );
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
if ( !$this->invalidEventType ) {
|
|
|
|
$this->output( "There is nothing to process\n" );
|
2015-10-01 13:48:52 +00:00
|
|
|
|
2013-01-15 23:21:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-11 14:00:00 +00:00
|
|
|
global $wgEchoCluster;
|
|
|
|
|
2013-04-09 22:13:39 +00:00
|
|
|
$dbw = MWEchoDbFactory::getDB( DB_MASTER );
|
|
|
|
$dbr = MWEchoDbFactory::getDB( DB_SLAVE );
|
2013-01-15 23:21:39 +00:00
|
|
|
|
|
|
|
$count = $this->batchSize;
|
|
|
|
|
|
|
|
while ( $count == $this->batchSize ) {
|
|
|
|
$res = $dbr->select(
|
|
|
|
array( 'echo_event' ),
|
|
|
|
array( 'event_id' ),
|
|
|
|
array(
|
|
|
|
'event_type' => $this->invalidEventType,
|
|
|
|
),
|
|
|
|
__METHOD__,
|
|
|
|
array( 'LIMIT' => $this->batchSize )
|
|
|
|
);
|
|
|
|
|
|
|
|
$event = array();
|
|
|
|
$count = 0;
|
2015-10-01 13:48:52 +00:00
|
|
|
foreach ( $res as $row ) {
|
2013-01-15 23:21:39 +00:00
|
|
|
if ( !in_array( $row->event_id, $event ) ) {
|
|
|
|
$event[] = $row->event_id;
|
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( $event ) {
|
|
|
|
$dbw->begin();
|
|
|
|
|
|
|
|
$dbw->delete(
|
|
|
|
'echo_event',
|
|
|
|
array( 'event_id' => $event ),
|
|
|
|
__METHOD__
|
|
|
|
);
|
|
|
|
$dbw->delete(
|
|
|
|
'echo_notification',
|
|
|
|
array( 'notification_event' => $event ),
|
|
|
|
__METHOD__
|
|
|
|
);
|
|
|
|
|
|
|
|
$dbw->commit();
|
|
|
|
|
|
|
|
$this->output( "processing " . count( $event ) . " invalid events\n" );
|
2013-04-11 14:00:00 +00:00
|
|
|
wfWaitForSlaves( false, false, $wgEchoCluster );
|
2013-01-15 23:21:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup is not necessary for
|
2013-03-26 00:57:42 +00:00
|
|
|
// 1. echo_email_batch, invalid notification is removed during the cron
|
2013-01-15 23:21:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = 'removeInvalidNotification'; // Tells it to run the class
|
|
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|