mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
Merge "Maintenance script sends notifications immediately"
This commit is contained in:
commit
5bcdfc6607
|
@ -35,9 +35,13 @@ abstract class MWEchoEmailBatch {
|
||||||
* 1 - once everyday
|
* 1 - once everyday
|
||||||
* 7 - once every 7 days
|
* 7 - once every 7 days
|
||||||
* @param $userId int
|
* @param $userId int
|
||||||
|
* @param $enforceFrequency boolean Whether or not email sending frequency should be enforced.
|
||||||
|
* When true, today's notifications won't be returned if their are
|
||||||
|
* configured to go out tonight or at the end of the week.
|
||||||
|
* When false, all pending notifications will be returned.
|
||||||
* @return MWEchoEmailBatch/false
|
* @return MWEchoEmailBatch/false
|
||||||
*/
|
*/
|
||||||
public static function newFromUserId( $userId ) {
|
public static function newFromUserId( $userId, $enforceFrequency = true ) {
|
||||||
$batchClassName = self::getEmailBatchClass();
|
$batchClassName = self::getEmailBatchClass();
|
||||||
|
|
||||||
$user = User::newFromId( intval( $userId ) );
|
$user = User::newFromId( intval( $userId ) );
|
||||||
|
@ -71,7 +75,7 @@ abstract class MWEchoEmailBatch {
|
||||||
if ( $userLastBatch ) {
|
if ( $userLastBatch ) {
|
||||||
// use 20 as hours per day to get estimate
|
// use 20 as hours per day to get estimate
|
||||||
$nextBatch = wfTimestamp( TS_UNIX, $userLastBatch ) + $userEmailSetting * 20 * 60 * 60;
|
$nextBatch = wfTimestamp( TS_UNIX, $userLastBatch ) + $userEmailSetting * 20 * 60 * 60;
|
||||||
if ( wfTimestamp( TS_MW, $nextBatch ) > wfTimestampNow() ) {
|
if ( $enforceFrequency && wfTimestamp( TS_MW, $nextBatch ) > wfTimestampNow() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,18 @@ class ProcessEchoEmailBatch extends Maintenance {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->mDescription = "Process email digest";
|
$this->mDescription = "Process email digest";
|
||||||
|
|
||||||
|
$this->addOption(
|
||||||
|
"ignoreConfiguredSchedule",
|
||||||
|
"Send all pending notifications immediately even if configured to be weekly or daily.",
|
||||||
|
false, false, "i" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
global $wgEchoCluster;
|
global $wgEchoCluster;
|
||||||
|
|
||||||
|
$ignoreConfiguredSchedule = $this->getOption( "ignoreConfiguredSchedule", 0 );
|
||||||
|
|
||||||
$this->output( "Started processing... \n" );
|
$this->output( "Started processing... \n" );
|
||||||
|
|
||||||
$startUserId = 0;
|
$startUserId = 0;
|
||||||
|
@ -39,7 +46,7 @@ class ProcessEchoEmailBatch extends Maintenance {
|
||||||
foreach ( $res as $row ) {
|
foreach ( $res as $row ) {
|
||||||
$userId = intval( $row->eeb_user_id );
|
$userId = intval( $row->eeb_user_id );
|
||||||
if ( $userId && $userId > $startUserId ) {
|
if ( $userId && $userId > $startUserId ) {
|
||||||
$emailBatch = MWEchoEmailBatch::newFromUserId( $userId );
|
$emailBatch = MWEchoEmailBatch::newFromUserId( $userId, !$ignoreConfiguredSchedule );
|
||||||
if ( $emailBatch ) {
|
if ( $emailBatch ) {
|
||||||
$this->output( "processing user_Id " . $userId . " \n" );
|
$this->output( "processing user_Id " . $userId . " \n" );
|
||||||
$emailBatch->process();
|
$emailBatch->process();
|
||||||
|
|
Loading…
Reference in a new issue