mediawiki-extensions-Echo/maintenance/processEchoEmailBatch.php
Kunal Mehta aaf061c725 build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.ExtraParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.Commenting.FunctionComment.WrongStyle
* MediaWiki.FunctionComment.Missing.Protected
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I8401abf121a7413fa191d7bc535e0ddd6cf8c3f7
2017-06-22 14:13:28 +00:00

81 lines
1.9 KiB
PHP

<?php
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
}
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";
$this->addOption(
"ignoreConfiguredSchedule",
"Send all pending notifications immediately even if configured to be weekly or daily.",
false, false, "i" );
$this->requireExtension( 'Echo' );
}
public function execute() {
global $wgEchoCluster;
if ( !class_exists( 'EchoHooks' ) ) {
$this->error( "Echo isn't enabled on this wiki\n", 1 );
}
$ignoreConfiguredSchedule = $this->getOption( "ignoreConfiguredSchedule", 0 );
$this->output( "Started processing... \n" );
$startUserId = 0;
$count = $this->batchSize;
while ( $count === $this->batchSize ) {
$count = 0;
$res = MWEchoEmailBatch::getUsersToNotify( $startUserId, $this->batchSize );
$updated = false;
foreach ( $res as $row ) {
$userId = intval( $row->eeb_user_id );
if ( $userId && $userId > $startUserId ) {
$emailBatch = MWEchoEmailBatch::newFromUserId( $userId, !$ignoreConfiguredSchedule );
if ( $emailBatch ) {
$this->output( "processing user_Id " . $userId . " \n" );
$emailBatch->process();
}
$startUserId = $userId;
$updated = true;
}
$count++;
}
wfWaitForSlaves( false, false, $wgEchoCluster );
// This is required since we are updating user properties in main wikidb
wfWaitForSlaves();
// double check to make sure that the id is updated
if ( !$updated ) {
break;
}
}
$this->output( "Completed \n" );
}
}
$maintClass = "ProcessEchoEmailBatch";
require_once DO_MAINTENANCE;