diff --git a/src/Controller/JobController.php b/src/Controller/JobController.php index 88ac242..69e662a 100644 --- a/src/Controller/JobController.php +++ b/src/Controller/JobController.php @@ -26,7 +26,7 @@ class JobController extends ControllerBase { */ public function runCronJob(CronJob $ultimate_cron_job) { $ultimate_cron_job->run(); - drupal_set_message($this->t('Cron job @job_label was successfully run.', ['@job_label' => $ultimate_cron_job->label()])); + drupal_set_message($this->t('Cron job @job_label (@module) was successfully run.', ['@job_label' => $ultimate_cron_job->label(), '@module' => $ultimate_cron_job->getModuleName()])); return $this->redirect('entity.ultimate_cron_job.collection'); } diff --git a/src/CronJobInterface.php b/src/CronJobInterface.php index b95c172..5fe0f9f 100644 --- a/src/CronJobInterface.php +++ b/src/CronJobInterface.php @@ -208,11 +208,6 @@ interface CronJobInterface extends ConfigEntityInterface { public function isBehindSchedule(); /** - * Launch job. - */ - public function launch(); - - /** * Lock job. */ public function lock(); diff --git a/src/Entity/CronJob.php b/src/Entity/CronJob.php index 9085797..eb54248 100644 --- a/src/Entity/CronJob.php +++ b/src/Entity/CronJob.php @@ -332,18 +332,6 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { } /** - * Launch job. - */ - public function launch() { - CronPlugin::hook_cron_pre_launch($this); - \Drupal::moduleHandler()->invokeAll('cron_pre_launch', array($this)); - $result = $this->getPlugin('launcher')->launch($this); - CronPlugin::hook_cron_post_launch($this); - \Drupal::moduleHandler()->invokeAll('cron_post_launch', array($this)); - return $result; - } - - /** * Lock job. */ public function lock() { diff --git a/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php b/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php index d334875..e452b29 100644 --- a/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php +++ b/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php @@ -10,6 +10,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Utility\Error; use Drupal\ultimate_cron\CronJobInterface; +use Drupal\ultimate_cron\CronPlugin; use Drupal\ultimate_cron\Launcher\LauncherBase; use Drupal\ultimate_cron\PluginCleanupInterface; @@ -204,6 +205,9 @@ class SerialLauncher extends LauncherBase implements PluginCleanupInterface { * {@inheritdoc} */ public function launch(CronJobInterface $job) { + CronPlugin::hook_cron_pre_launch($this); + \Drupal::moduleHandler()->invokeAll('cron_pre_launch', array($this)); + $lock_id = $job->lock(); if (!$lock_id) { @@ -219,11 +223,6 @@ class SerialLauncher extends LauncherBase implements PluginCleanupInterface { } $log_entry = $job->startLog($lock_id, $init_message); - drupal_set_message(t('@name: @init_message', array( - '@name' => $job->id(), - '@init_message' => $init_message, - ))); - // Run job. try { $job->run(); @@ -247,6 +246,9 @@ class SerialLauncher extends LauncherBase implements PluginCleanupInterface { finally { $log_entry->finish(); $job->unlock($lock_id); + + CronPlugin::hook_cron_post_launch($this); + \Drupal::moduleHandler()->invokeAll('cron_post_launch', array($this)); } return TRUE; } @@ -366,7 +368,7 @@ class SerialLauncher extends LauncherBase implements PluginCleanupInterface { break; } if ((!self::getGlobalOption('thread') || $configuration['launcher']['thread'] == $thread) && $job->isScheduled()) { - $job->launch(); + $this->launch($job); // Be friendly, and check if someone else has taken the lock. // If they have, bail out, since someone else is now handling // this thread.