This commit refactors the method processTaskStrategy() of some SimpleWorker child classes to use Doctrine instead of Paris. In this commit are included all the classes that it was only necessary to change the method signature as they were receiving a ScheduledTask object as the first parameter but didn't use it. Now they receive a ScheduledTaskEntity object as the first param. [MAILPOET-3843]
36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace MailPoet\Cron\Workers;
|
|
|
|
use MailPoet\Entities\ScheduledTaskEntity;
|
|
use MailPoet\Models\Subscriber;
|
|
use MailPoet\WP\Functions as WPFunctions;
|
|
use MailPoetVendor\Carbon\Carbon;
|
|
use MailPoetVendor\Idiorm\ORM;
|
|
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
class SubscriberLinkTokens extends SimpleWorker {
|
|
const TASK_TYPE = 'subscriber_link_tokens';
|
|
const BATCH_SIZE = 10000;
|
|
const AUTOMATIC_SCHEDULING = false;
|
|
|
|
public function processTaskStrategy(ScheduledTaskEntity $task, $timer) {
|
|
$count = Subscriber::whereNull('link_token')->count();
|
|
if ($count) {
|
|
$authKey = defined('AUTH_KEY') ? AUTH_KEY : '';
|
|
ORM::rawExecute(
|
|
sprintf('UPDATE %s SET link_token = SUBSTRING(MD5(CONCAT(?, email)), 1, ?) WHERE link_token IS NULL LIMIT ?', Subscriber::$_table),
|
|
[$authKey, Subscriber::OBSOLETE_LINK_TOKEN_LENGTH, self::BATCH_SIZE]
|
|
);
|
|
$this->schedule();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function getNextRunDate() {
|
|
$wp = new WPFunctions();
|
|
return Carbon::createFromTimestamp($wp->currentTime('timestamp'));
|
|
}
|
|
}
|