Skip to content

Commit

Permalink
Fix(defaultJobs) config now loads correctly. Add SS_Log of missing jo…
Browse files Browse the repository at this point in the history
…b. Change admin email queued_job_admin_email
  • Loading branch information
Stephen McMahon committed Jul 18, 2017
1 parent 3c6fbcb commit 59f0cb9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions code/services/QueuedJobService.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class QueuedJobService {
* Config controlled list of default/required jobs
* @var Array
*/
public $defaultJobs;
public $defaultJobs = array();

/**
* Register our shutdown handler
Expand Down Expand Up @@ -325,6 +325,9 @@ public function checkJobHealth($queue = null) {
*/
public function checkdefaultJobs($queue = null) {
$queue = $queue ?: QueuedJob::QUEUED;

$this->defaultJobs = !empty($this->defaultJobs) ? $this->defaultJobs : Config::inst()->get(__CLASS__, 'defaultJobs');

if (count($this->defaultJobs)) {

$activeJobs = QueuedJobDescriptor::get()->filter(array(
Expand All @@ -349,16 +352,18 @@ public function checkdefaultJobs($queue = null) {
));

if (!$job->count()) {
SS_Log::log("Default Job config: $title was missing from Queue and has been re-added", SS_Log::ERR);
Email::create()
->setTo(isset($jobConfig['email']) ? $jobConfig['email'] : Email::config()->admin_email)
->setTo(isset($jobConfig['email']) ? $jobConfig['email'] : Config::inst()->get('Email', 'queued_job_admin_email'))
->setFrom(Config::inst()->get('Email', 'queued_job_admin_email'))
->setSubject('Default Job "' . $title . '" missing')
->populateTemplate(array('Title' => $title, 'Site' => Director::absoluteBaseURL()))
->populateTemplate($jobConfig)
->setTemplate('QueuedJobsDefaultJob')
->send();

if (isset($jobConfig['recreate']) && $jobConfig['recreate']) {
if (!isset($jobConfig['construct']) || !isset($jobConfig['startDateFormat']) || !isset($jobConfig['startTimeString'])) {
if (!array_key_exists('construct', $jobConfig) || !isset($jobConfig['startDateFormat']) || !isset($jobConfig['startTimeString'])) {
SS_Log::log("Default Job config: $title incorrectly set up. Please check the readme for examples", SS_Log::ERR);
continue;
}
Expand Down

0 comments on commit 59f0cb9

Please sign in to comment.