2012-11-27 01:53:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
if ( $IP === false ) {
|
|
|
|
$IP = dirname( __FILE__ ) . '/../..';
|
|
|
|
}
|
|
|
|
require_once( "$IP/maintenance/Maintenance.php" );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A maintenance script that processes email digest
|
|
|
|
*/
|
|
|
|
class processEchoEmailBatch extends Maintenance {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Max number of records to process at a time
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $batchSize = 300;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->mDescription = "Process email digest";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute() {
|
2013-04-11 14:00:00 +00:00
|
|
|
global $wgEchoCluster;
|
|
|
|
|
2012-11-27 01:53:35 +00:00
|
|
|
$this->output( "Started processing... \n" );
|
|
|
|
|
|
|
|
$startUserId = 0;
|
|
|
|
$count = $this->batchSize;
|
|
|
|
|
|
|
|
while ( $count === $this->batchSize ) {
|
|
|
|
$count = 0;
|
2013-01-15 23:21:39 +00:00
|
|
|
|
|
|
|
$res = MWEchoEmailBatch::getUsersToNotify( $startUserId, $this->batchSize );
|
2012-11-27 01:53:35 +00:00
|
|
|
|
|
|
|
$updated = false;
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
$userId = intval( $row->eeb_user_id );
|
|
|
|
if ( $userId && $userId > $startUserId ) {
|
|
|
|
$emailBatch = MWEchoEmailBatch::newFromUserId( $userId );
|
|
|
|
if ( $emailBatch ) {
|
|
|
|
$this->output( "processing user_Id " . $userId . " \n" );
|
|
|
|
$emailBatch->process();
|
|
|
|
}
|
|
|
|
$startUserId = $userId;
|
|
|
|
$updated = true;
|
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
}
|
2013-04-11 14:00:00 +00:00
|
|
|
wfWaitForSlaves( false, false, $wgEchoCluster );
|
2012-11-27 01:53:35 +00:00
|
|
|
|
|
|
|
// double check to make sure that the id is updated
|
|
|
|
if ( !$updated ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->output( "Completed \n" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = "processEchoEmailBatch";
|
|
|
|
require_once( DO_MAINTENANCE );
|