diff --git a/src/Controllers/QueuedJobsAdmin.php b/src/Controllers/QueuedJobsAdmin.php
index 6ac8c86a..1b95c573 100644
--- a/src/Controllers/QueuedJobsAdmin.php
+++ b/src/Controllers/QueuedJobsAdmin.php
@@ -135,7 +135,7 @@ public function getEditForm($id = null, $fields = null)
if (QueuedJobDescriptor::singleton()->canCreate()) {
$types = ClassInfo::subclassesFor(AbstractQueuedJob::class);
- $types = array_combine($types, $types);
+ $types = array_combine($types ?? [], $types ?? []);
foreach ($types as $class) {
$reflection = new ReflectionClass($class);
if (!$reflection->isInstantiable()) {
@@ -200,10 +200,10 @@ public function createjob($data, Form $form)
// If the user has select the European date format as their setting then replace '/' with '-' in the
// date string so PHP treats the date as this format.
if (Security::getCurrentUser()->DateFormat == self::$date_format_european) {
- $time = str_replace('/', '-', $time);
+ $time = str_replace('/', '-', $time ?? '');
}
- if ($jobType && class_exists($jobType) && is_subclass_of($jobType, QueuedJob::class)) {
+ if ($jobType && class_exists($jobType ?? '') && is_subclass_of($jobType, QueuedJob::class)) {
$jobClass = new ReflectionClass($jobType);
$job = $jobClass->newInstanceArgs($params);
if ($this->jobQueue->queueJob($job, $time)) {
diff --git a/src/Controllers/QueuedTaskRunner.php b/src/Controllers/QueuedTaskRunner.php
index 76269284..ad226822 100644
--- a/src/Controllers/QueuedTaskRunner.php
+++ b/src/Controllers/QueuedTaskRunner.php
@@ -89,13 +89,13 @@ public function index()
// universal tasks
foreach ($tasks as $task) {
- if (in_array($task['class'], $blacklist)) {
+ if (in_array($task['class'], $blacklist ?? [])) {
$backlistedTasks[] = $task;
continue;
}
- if (in_array($task['class'], $queuedOnlyList)) {
+ if (in_array($task['class'], $queuedOnlyList ?? [])) {
$queuedOnlyTasks[] = $task;
continue;
@@ -162,7 +162,7 @@ public function queueTask($request)
unset($variables['flush']);
unset($variables['flushtoken']);
unset($variables['isDev']);
- $querystring = http_build_query($variables);
+ $querystring = http_build_query($variables ?? []);
$title = function ($content) {
printf(Director::is_cli() ? "%s\n\n" : '
%s
', $content);
diff --git a/src/DataObjects/QueuedJobDescriptor.php b/src/DataObjects/QueuedJobDescriptor.php
index e4c73c5d..d5256317 100644
--- a/src/DataObjects/QueuedJobDescriptor.php
+++ b/src/DataObjects/QueuedJobDescriptor.php
@@ -244,7 +244,7 @@ protected function getJobDir()
$jobDir = TEMP_FOLDER . '/' . $jobDir;
}
- if (!is_dir($jobDir)) {
+ if (!is_dir($jobDir ?? '')) {
Filesystem::makeFolder($jobDir);
}
return $jobDir;
@@ -264,8 +264,8 @@ public function cleanupJob()
{
// remove the job's temp file if it exists
$tmpFile = $this->getJobDir() . '/queuedjob-' . $this->ID;
- if (file_exists($tmpFile)) {
- unlink($tmpFile);
+ if (file_exists($tmpFile ?? '')) {
+ unlink($tmpFile ?? '');
}
}
@@ -294,8 +294,8 @@ public function onBeforeDelete()
*/
public function getMessages()
{
- if (strlen($this->SavedJobMessages)) {
- $messages = @unserialize($this->SavedJobMessages);
+ if (strlen($this->SavedJobMessages ?? '')) {
+ $messages = @unserialize($this->SavedJobMessages ?? '');
if (!empty($messages)) {
return DBField::create_field(
'HTMLText',
@@ -313,9 +313,9 @@ public function getMessages()
*/
public function getLastMessage()
{
- if (strlen($this->SavedJobMessages)) {
- $msgs = @unserialize($this->SavedJobMessages);
- if (is_array($msgs) && sizeof($msgs)) {
+ if (strlen($this->SavedJobMessages ?? '')) {
+ $msgs = @unserialize($this->SavedJobMessages ?? '');
+ if (is_array($msgs) && sizeof($msgs ?? [])) {
return array_pop($msgs);
}
}
@@ -432,7 +432,7 @@ public function getCMSFields()
)
),
$jobTitle = TextField::create('JobTitle', 'Title'),
- $status = DropdownField::create('JobStatus', 'Status', array_combine($statuses, $statuses)),
+ $status = DropdownField::create('JobStatus', 'Status', array_combine($statuses ?? [], $statuses ?? [])),
$jobType = DropdownField::create('JobType', 'Queue type', $this->getJobTypeValues()),
$runAs,
$startAfter = DatetimeField::create('StartAfter', 'Scheduled Start Time'),
@@ -547,7 +547,7 @@ public function getCMSFields()
)
);
- if (strlen($this->SavedJobMessages)) {
+ if (strlen($this->SavedJobMessages ?? '')) {
$fields->addFieldToTab('Root.Messages', LiteralField::create('Messages', $this->getMessages()));
}
diff --git a/src/Forms/GridFieldQueuedJobExecute.php b/src/Forms/GridFieldQueuedJobExecute.php
index 8d30b012..af6dc10f 100644
--- a/src/Forms/GridFieldQueuedJobExecute.php
+++ b/src/Forms/GridFieldQueuedJobExecute.php
@@ -59,7 +59,7 @@ public function __construct($action = 'execute', $check = null)
*/
public function augmentColumns($gridField, &$columns)
{
- if (!in_array('Actions', $columns)) {
+ if (!in_array('Actions', $columns ?? [])) {
$columns[] = 'Actions';
}
}
@@ -138,7 +138,7 @@ public function getColumnContent($gridField, $record, $columnName)
array('RecordID' => $record->ID)
);
- $humanTitle = ucfirst($this->action);
+ $humanTitle = ucfirst($this->action ?? '');
$title = _t(__CLASS__ . '.' . $humanTitle, $humanTitle);
$field
@@ -163,7 +163,7 @@ public function getColumnContent($gridField, $record, $columnName)
public function handleAction(GridField $gridField, $actionName, $arguments, $data)
{
$actions = $this->getActions(null);
- if (in_array($actionName, $actions)) {
+ if (in_array($actionName, $actions ?? [])) {
$item = $gridField->getList()->byID($arguments['RecordID']);
if (!$item) {
return;
diff --git a/src/Jobs/CleanupJob.php b/src/Jobs/CleanupJob.php
index 0cb242e2..92b873f3 100644
--- a/src/Jobs/CleanupJob.php
+++ b/src/Jobs/CleanupJob.php
@@ -152,7 +152,7 @@ public function process()
$this->reenqueue();
return;
}
- $numJobs = count($staleJobs);
+ $numJobs = count($staleJobs ?? []);
$staleJobs = implode('\', \'', $staleJobs);
DB::query('DELETE FROM "QueuedJobDescriptor"
WHERE "ID"
diff --git a/src/Jobs/DoormanQueuedJobTask.php b/src/Jobs/DoormanQueuedJobTask.php
index 039acd88..be60bfb8 100644
--- a/src/Jobs/DoormanQueuedJobTask.php
+++ b/src/Jobs/DoormanQueuedJobTask.php
@@ -119,7 +119,7 @@ public function serialize()
*/
public function unserialize($serialized)
{
- $data = unserialize($serialized);
+ $data = unserialize($serialized ?? '');
$this->__unserialize($data);
}
@@ -233,7 +233,7 @@ public function isCancelled()
];
if ($this->descriptor) {
- return in_array($this->descriptor->JobStatus, $cancelledStates, true);
+ return in_array($this->descriptor->JobStatus, $cancelledStates ?? [], true);
}
return true;
diff --git a/src/Jobs/GenerateGoogleSitemapJob.php b/src/Jobs/GenerateGoogleSitemapJob.php
index ac8abc7d..08d52794 100644
--- a/src/Jobs/GenerateGoogleSitemapJob.php
+++ b/src/Jobs/GenerateGoogleSitemapJob.php
@@ -39,7 +39,7 @@ public function __construct()
{
$this->pagesToProcess = DB::query('SELECT ID FROM "SiteTree_Live" WHERE "ShowInSearch"=1')->column();
$this->currentStep = 0;
- $this->totalSteps = count($this->pagesToProcess);
+ $this->totalSteps = count($this->pagesToProcess ?? []);
}
/**
@@ -81,9 +81,9 @@ public function setup()
Environment::increaseTimeLimitTo();
$restart = $this->currentStep == 0;
- if (!$this->tempFile || !file_exists($this->tempFile)) {
- $tmpfile = tempnam(TempFolder::getTempFolder(BASE_PATH), 'sitemap');
- if (file_exists($tmpfile)) {
+ if (!$this->tempFile || !file_exists($this->tempFile ?? '')) {
+ $tmpfile = tempnam(TempFolder::getTempFolder(BASE_PATH) ?? '', 'sitemap');
+ if (file_exists($tmpfile ?? '')) {
$this->tempFile = $tmpfile;
}
$restart = true;
@@ -101,9 +101,9 @@ public function prepareForRestart()
{
parent::prepareForRestart();
// if the file we've been building is missing, lets fix it up
- if (!$this->tempFile || !file_exists($this->tempFile)) {
- $tmpfile = tempnam(TempFolder::getTempFolder(BASE_PATH), 'sitemap');
- if (file_exists($tmpfile)) {
+ if (!$this->tempFile || !file_exists($this->tempFile ?? '')) {
+ $tmpfile = tempnam(TempFolder::getTempFolder(BASE_PATH) ?? '', 'sitemap');
+ if (file_exists($tmpfile ?? '')) {
$this->tempFile = $tmpfile;
}
$this->currentStep = 0;
@@ -117,14 +117,14 @@ public function process()
throw new Exception("Temporary sitemap file has not been set");
}
- if (!file_exists($this->tempFile)) {
+ if (!file_exists($this->tempFile ?? '')) {
throw new Exception("Temporary file $this->tempFile has been deleted!");
}
$remainingChildren = $this->pagesToProcess;
// if there's no more, we're done!
- if (!count($remainingChildren)) {
+ if (!count($remainingChildren ?? [])) {
$this->completeJob();
$this->isComplete = true;
return;
@@ -172,11 +172,11 @@ public function process()
// do the generation of the file in a temporary location
$content = $page->renderWith('SitemapEntry');
- $fp = fopen($this->tempFile, "a");
+ $fp = fopen($this->tempFile ?? '', "a");
if (!$fp) {
throw new Exception("Could not open $this->tempFile for writing");
}
- fputs($fp, $content, strlen($content));
+ fputs($fp, $content ?? '', strlen($content ?? ''));
fclose($fp);
}
}
@@ -185,7 +185,7 @@ public function process()
$this->pagesToProcess = $remainingChildren;
$this->currentStep++;
- if (!count($remainingChildren)) {
+ if (!count($remainingChildren ?? [])) {
$this->completeJob();
$this->isComplete = true;
return;
@@ -199,15 +199,15 @@ protected function completeJob()
{
$content = '' .
'';
- $content .= file_get_contents($this->tempFile);
+ $content .= file_get_contents($this->tempFile ?? '');
$content .= '';
$sitemap = Director::baseFolder() . '/sitemap.xml';
- file_put_contents($sitemap, $content);
+ file_put_contents($sitemap ?? '', $content);
- if (file_exists($this->tempFile)) {
- unlink($this->tempFile);
+ if (file_exists($this->tempFile ?? '')) {
+ unlink($this->tempFile ?? '');
}
$nextgeneration = Injector::inst()->create(GenerateGoogleSitemapJob::class);
diff --git a/src/Jobs/PublishItemsJob.php b/src/Jobs/PublishItemsJob.php
index e17ebbfd..69ec26ca 100644
--- a/src/Jobs/PublishItemsJob.php
+++ b/src/Jobs/PublishItemsJob.php
@@ -105,7 +105,7 @@ public function process()
$remainingChildren = $this->remainingChildren;
// if there's no more, we're done!
- if (!count($remainingChildren)) {
+ if (!count($remainingChildren ?? [])) {
$this->isComplete = true;
return;
}
@@ -137,7 +137,7 @@ public function process()
// and now we store the new list of remaining children
$this->remainingChildren = $remainingChildren;
- if (!count($remainingChildren)) {
+ if (!count($remainingChildren ?? [])) {
$this->isComplete = true;
return;
}
diff --git a/src/Jobs/RunBuildTaskJob.php b/src/Jobs/RunBuildTaskJob.php
index 18749ad5..775fb478 100644
--- a/src/Jobs/RunBuildTaskJob.php
+++ b/src/Jobs/RunBuildTaskJob.php
@@ -82,7 +82,7 @@ public function process()
}
$getVars = [];
- parse_str($this->QueryString, $getVars);
+ parse_str($this->QueryString ?? '', $getVars);
$request = new HTTPRequest('GET', '/', $getVars);
$task->run($request);
diff --git a/src/Jobs/ScheduledExecutionJob.php b/src/Jobs/ScheduledExecutionJob.php
index 514e27a1..108a85cd 100644
--- a/src/Jobs/ScheduledExecutionJob.php
+++ b/src/Jobs/ScheduledExecutionJob.php
@@ -75,7 +75,7 @@ public function process()
$timeStr = '+' . $executeInterval . ' ' . $object->ExecuteEvery;
}
- $next = strtotime($timeStr);
+ $next = strtotime($timeStr ?? '');
if ($next > DBDatetime::now()->getTimestamp()) {
// in the future
$nextGen = DBDatetime::create()->setValue($next)->Rfc2822();
diff --git a/src/QJUtils.php b/src/QJUtils.php
index 58552dd9..78778c6f 100644
--- a/src/QJUtils.php
+++ b/src/QJUtils.php
@@ -33,13 +33,13 @@ public function dbQuote($filter = array(), $join = " AND ")
// first break the field up into its two components
$operator = '';
if (is_string($field)) {
- list($field, $operator) = explode(' ', trim($field));
+ list($field, $operator) = explode(' ', trim($field ?? ''));
}
$value = $this->recursiveQuote($value);
- if (strpos($field, '.')) {
- list($tb, $fl) = explode('.', $field);
+ if (strpos($field ?? '', '.')) {
+ list($tb, $fl) = explode('.', $field ?? '');
$string .= $sep . $quoteChar . $tb . $quoteChar . '.' . $quoteChar . $fl . $quoteChar
. " $operator " . $value;
} else {
diff --git a/src/Services/AbstractQueuedJob.php b/src/Services/AbstractQueuedJob.php
index 1c845aad..f47604bb 100644
--- a/src/Services/AbstractQueuedJob.php
+++ b/src/Services/AbstractQueuedJob.php
@@ -243,7 +243,7 @@ private function loadCustomConfig()
*/
public function addMessage($message, $severity = 'INFO')
{
- $severity = strtoupper($severity);
+ $severity = strtoupper($severity ?? '');
$this->messages[] = '[' . DBDatetime::now()->Rfc2822() . "][$severity] $message";
}
diff --git a/src/Services/EmailService.php b/src/Services/EmailService.php
index 60b23e64..0aae9d19 100644
--- a/src/Services/EmailService.php
+++ b/src/Services/EmailService.php
@@ -44,7 +44,7 @@ public function createMissingDefaultJobReport(array $jobConfig, string $title):
{
$subject = sprintf('Default Job "%s" missing', $title);
$from = Config::inst()->get(Email::class, 'queued_job_admin_email');
- $to = array_key_exists('email', $jobConfig) && $jobConfig['email']
+ $to = array_key_exists('email', $jobConfig ?? []) && $jobConfig['email']
? $jobConfig['email']
: $from;
diff --git a/src/Services/GearmanQueueHandler.php b/src/Services/GearmanQueueHandler.php
index 164f920a..f2596d1e 100644
--- a/src/Services/GearmanQueueHandler.php
+++ b/src/Services/GearmanQueueHandler.php
@@ -36,6 +36,6 @@ public function startJobOnQueue(QueuedJobDescriptor $job)
*/
public function scheduleJob(QueuedJobDescriptor $job, $date)
{
- $this->gearmanService->sendJob('scheduled', 'jobqueueExecute', array($job->ID), strtotime($date));
+ $this->gearmanService->sendJob('scheduled', 'jobqueueExecute', array($job->ID), strtotime($date ?? ''));
}
}
diff --git a/src/Services/QueuedJobService.php b/src/Services/QueuedJobService.php
index c7490055..0093cdc1 100644
--- a/src/Services/QueuedJobService.php
+++ b/src/Services/QueuedJobService.php
@@ -303,7 +303,7 @@ public function queueJob(QueuedJob $job, $startAfter = null, $userId = null, $qu
*/
public function startJob($jobDescriptor, $startAfter = null)
{
- if ($startAfter && strtotime($startAfter) > DBDatetime::now()->getTimestamp()) {
+ if ($startAfter && strtotime($startAfter ?? '') > DBDatetime::now()->getTimestamp()) {
$this->queueHandler->scheduleJob($jobDescriptor, $startAfter);
} else {
// immediately start it on the queue, however that works
@@ -365,12 +365,12 @@ protected function copyDescriptorToJob($jobDescriptor, $job)
$messages = null;
// switching to php's serialize methods... not sure why this wasn't done from the start!
- $jobData = @unserialize($jobDescriptor->SavedJobData);
- $messages = @unserialize($jobDescriptor->SavedJobMessages);
+ $jobData = @unserialize($jobDescriptor->SavedJobData ?? '');
+ $messages = @unserialize($jobDescriptor->SavedJobMessages ?? '');
// try decoding as json if null
- $jobData = $jobData ?: json_decode($jobDescriptor->SavedJobData);
- $messages = $messages ?: json_decode($jobDescriptor->SavedJobMessages);
+ $jobData = $jobData ?: json_decode($jobDescriptor->SavedJobData ?? '');
+ $messages = $messages ?: json_decode($jobDescriptor->SavedJobMessages ?? '');
$job->setJobData(
$jobDescriptor->TotalSteps,
@@ -471,7 +471,7 @@ public function checkJobHealth($queue = null)
foreach ($stalledJobs as $stalledJob) {
$jobClass = $stalledJob->Implementation;
- if (!class_exists($jobClass)) {
+ if (!class_exists($jobClass ?? '')) {
$stalledJob->delete();
continue;
@@ -510,7 +510,7 @@ public function checkJobHealth($queue = null)
'broken' => $brokenIDs,
];
- if (count($brokenIDs) === 0) {
+ if (count($brokenIDs ?? []) === 0) {
return $result;
}
@@ -522,7 +522,7 @@ public function checkJobHealth($queue = null)
]
);
- $placeholders = implode(', ', array_fill(0, count($brokenIDs), '?'));
+ $placeholders = implode(', ', array_fill(0, count($brokenIDs ?? []), '?'));
$query = SQLUpdate::create(
'"QueuedJobDescriptor"',
['"NotifiedBroken"' => 1],
@@ -540,7 +540,7 @@ public function checkJobHealth($queue = null)
public function checkDefaultJobs($queue = null)
{
$queue = $queue ?: QueuedJob::QUEUED;
- if (count($this->defaultJobs)) {
+ if (count($this->defaultJobs ?? [])) {
$activeJobs = QueuedJobDescriptor::get()->filter(
'JobStatus',
[
@@ -582,7 +582,7 @@ public function checkDefaultJobs($queue = null)
if (isset($jobConfig['recreate']) && $jobConfig['recreate']) {
if (
- !array_key_exists('construct', $jobConfig)
+ !array_key_exists('construct', $jobConfig ?? [])
|| !isset($jobConfig['startDateFormat'])
|| !isset($jobConfig['startTimeString'])
) {
@@ -597,7 +597,7 @@ public function checkDefaultJobs($queue = null)
}
QueuedJobService::singleton()->queueJob(
Injector::inst()->createWithArgs($jobConfig['type'], $jobConfig['construct']),
- date($jobConfig['startDateFormat'], strtotime($jobConfig['startTimeString']))
+ date($jobConfig['startDateFormat'] ?? '', strtotime($jobConfig['startTimeString'] ?? ''))
);
$this->getLogger()->info(
"Default Job config: $title has been re-added to the Queue",
@@ -725,7 +725,7 @@ protected function grabMutex(QueuedJobDescriptor $jobDescriptor)
$row = DB::query(sprintf($query, Convert::raw2sql($descriptorId)))->first();
- if (!is_array($row) || !array_key_exists('ID', $row) || !$row['ID']) {
+ if (!is_array($row) || !array_key_exists('ID', $row ?? []) || !$row['ID']) {
throw new Exception('Failed to read job lock');
}
@@ -737,7 +737,7 @@ protected function grabMutex(QueuedJobDescriptor $jobDescriptor)
. ', "WorkerCount" = "WorkerCount" + 1 WHERE "ID" = %s';
DB::query(sprintf(
- $query,
+ $query ?? '',
Convert::raw2sql($expiry, true),
Convert::raw2sql($mutex, true),
Convert::raw2sql($descriptorId)
@@ -1010,7 +1010,7 @@ public function runJob($jobId)
// any messages added after this point will be auto-flushed on PHP shutdown through the handler.
// This causes a database write, and assumes the database and table will be available at this point.
if ($logger instanceof Logger) {
- $logger->setHandlers(array_filter($logger->getHandlers(), function ($handler) {
+ $logger->setHandlers(array_filter($logger->getHandlers() ?? [], function ($handler) {
return !($handler instanceof BufferHandler);
}));
}
@@ -1211,7 +1211,7 @@ protected function getMemoryLimit()
*/
protected function getPHPMemoryLimit()
{
- return $this->parseMemory(trim(ini_get("memory_limit")));
+ return $this->parseMemory(trim(ini_get("memory_limit") ?? ''));
}
/**
@@ -1224,17 +1224,17 @@ protected function getPHPMemoryLimit()
*/
protected function parseMemory($memString)
{
- switch (strtolower(substr($memString, -1))) {
+ switch (strtolower(substr($memString ?? '', -1))) {
case "b":
- return round(substr($memString, 0, -1));
+ return round(substr($memString ?? '', 0, -1));
case "k":
- return round(substr($memString, 0, -1) * 1024);
+ return round(substr($memString ?? '', 0, -1) * 1024);
case "m":
- return round(substr($memString, 0, -1) * 1024 * 1024);
+ return round(substr($memString ?? '', 0, -1) * 1024 * 1024);
case "g":
- return round(substr($memString, 0, -1) * 1024 * 1024 * 1024);
+ return round(substr($memString ?? '', 0, -1) * 1024 * 1024 * 1024);
default:
- return round($memString);
+ return round($memString ?? 0.0);
}
}
@@ -1389,7 +1389,7 @@ public function enableMaintenanceLock()
$path = $this->lockFilePath();
$contents = DBDatetime::now()->Rfc2822();
- file_put_contents($path, $contents);
+ file_put_contents($path ?? '', $contents);
}
public function disableMaintenanceLock()
@@ -1399,11 +1399,11 @@ public function disableMaintenanceLock()
}
$path = $this->lockFilePath();
- if (!file_exists($path)) {
+ if (!file_exists($path ?? '')) {
return;
}
- unlink($path);
+ unlink($path ?? '');
}
/**
@@ -1417,7 +1417,7 @@ public function isMaintenanceLockActive()
$path = $this->lockFilePath();
- return file_exists($path);
+ return file_exists($path ?? '');
}
/**
diff --git a/src/Tasks/CheckJobHealthTask.php b/src/Tasks/CheckJobHealthTask.php
index 606a27b2..d5544a2a 100644
--- a/src/Tasks/CheckJobHealthTask.php
+++ b/src/Tasks/CheckJobHealthTask.php
@@ -46,7 +46,7 @@ public function run($request)
$unhealthyJobCount = 0;
foreach ($jobHealth as $type => $IDs) {
- $count = count($IDs);
+ $count = count($IDs ?? []);
echo 'Detected and attempted restart on ' . $count . ' ' . $type . ' jobs';
$unhealthyJobCount = $unhealthyJobCount + $count;
}
diff --git a/src/Tasks/CreateQueuedJobTask.php b/src/Tasks/CreateQueuedJobTask.php
index 47c96b95..fa73f882 100644
--- a/src/Tasks/CreateQueuedJobTask.php
+++ b/src/Tasks/CreateQueuedJobTask.php
@@ -52,7 +52,7 @@ public function run($request)
}
if (isset($request['start'])) {
- $start = strtotime($request['start']);
+ $start = strtotime($request['start'] ?? '');
$now = DBDatetime::now()->getTimestamp();
if ($start >= $now) {
$friendlyStart = DBDatetime::create()->setValue($start)->Rfc2822();
diff --git a/src/Tasks/Engines/DoormanRunner.php b/src/Tasks/Engines/DoormanRunner.php
index 6ff2c419..0e4a6bbb 100644
--- a/src/Tasks/Engines/DoormanRunner.php
+++ b/src/Tasks/Engines/DoormanRunner.php
@@ -99,7 +99,7 @@ public function runQueue($queue)
);
$logPath = Environment::getEnv('SS_DOORMAN_LOGPATH');
- if ($logPath && is_dir($logPath) && is_writable($logPath)) {
+ if ($logPath && is_dir($logPath ?? '') && is_writable($logPath ?? '')) {
$manager->setLogPath($logPath);
}
@@ -155,7 +155,7 @@ public function runQueue($queue)
}
$tickCount += 1;
- sleep($this->getTickInterval());
+ sleep($this->getTickInterval() ?? 0);
$descriptor = $service->getNextPendingJob($queue);
}
}
diff --git a/src/Tasks/ProcessJobQueueChildTask.php b/src/Tasks/ProcessJobQueueChildTask.php
index fffa0c73..e6c5e51f 100644
--- a/src/Tasks/ProcessJobQueueChildTask.php
+++ b/src/Tasks/ProcessJobQueueChildTask.php
@@ -24,7 +24,7 @@ public function run($request)
return;
}
- $task = @unserialize(@base64_decode($_SERVER['argv'][2]));
+ $task = @unserialize(@base64_decode($_SERVER['argv'][2] ?? ''));
if ($task) {
$this->getService()->runJob($task->getDescriptor()->ID);
diff --git a/src/Tasks/ProcessJobQueueTask.php b/src/Tasks/ProcessJobQueueTask.php
index 6df09121..84df6ac8 100644
--- a/src/Tasks/ProcessJobQueueTask.php
+++ b/src/Tasks/ProcessJobQueueTask.php
@@ -74,9 +74,9 @@ public function run($request)
}
// Check if there is a job to run
- if (($job = $request->getVar('job')) && strpos($job, '-')) {
+ if (($job = $request->getVar('job')) && strpos($job ?? '', '-')) {
// Run from a isngle job
- $parts = explode('-', $job);
+ $parts = explode('-', $job ?? '');
$id = $parts[1];
$service->runJob($id);
return;
@@ -103,7 +103,7 @@ protected function getQueue($request)
$queue = 'Queued';
}
- switch (strtolower($queue)) {
+ switch (strtolower($queue ?? '')) {
case 'immediate':
$queue = QueuedJob::IMMEDIATE;
break;
diff --git a/src/Workers/JobWorker.php b/src/Workers/JobWorker.php
index af2ccc57..e3ca7669 100644
--- a/src/Workers/JobWorker.php
+++ b/src/Workers/JobWorker.php
@@ -42,7 +42,7 @@ public function jobqueueExecute($jobId)
$job = QueuedJobDescriptor::get()->byID($jobId);
if ($job) {
// check that we're not trying to execute something tooo soon
- if (strtotime($job->StartAfter) > DBDatetime::now()->getTimestamp()) {
+ if (strtotime($job->StartAfter ?? '') > DBDatetime::now()->getTimestamp()) {
return;
}
diff --git a/tests/MaintenanceLockTest.php b/tests/MaintenanceLockTest.php
index a2b7d91e..c6dcd9d5 100644
--- a/tests/MaintenanceLockTest.php
+++ b/tests/MaintenanceLockTest.php
@@ -30,11 +30,11 @@ public function testEnableMaintenanceIfActive($lockFileEnabled, $fileExists, $lo
QueuedJobService::singleton()->enableMaintenanceLock();
- $this->assertEquals($fileExists, file_exists($filePath));
+ $this->assertEquals($fileExists, file_exists($filePath ?? ''));
$this->assertEquals($lockActive, QueuedJobService::singleton()->isMaintenanceLockActive());
QueuedJobService::singleton()->disableMaintenanceLock();
- $this->assertFalse(file_exists($filePath));
+ $this->assertFalse(file_exists($filePath ?? ''));
$this->assertFalse(QueuedJobService::singleton()->isMaintenanceLockActive());
}
diff --git a/tests/QueuedJobsTest/QueuedJobsTest_RecordingLogger.php b/tests/QueuedJobsTest/QueuedJobsTest_RecordingLogger.php
index 8f4ce32c..474de732 100644
--- a/tests/QueuedJobsTest/QueuedJobsTest_RecordingLogger.php
+++ b/tests/QueuedJobsTest/QueuedJobsTest_RecordingLogger.php
@@ -48,9 +48,9 @@ public function clear()
public function filterMessages($containing)
{
return array_values(array_filter(
- $this->getMessages(),
+ $this->getMessages() ?? [],
function ($content) use ($containing) {
- return stripos($content, $containing) !== false;
+ return stripos($content ?? '', $containing ?? '') !== false;
}
));
}
@@ -68,6 +68,6 @@ public function countMessages($containing = null)
} else {
$messages = $this->getMessages();
}
- return count($messages);
+ return count($messages ?? []);
}
}
diff --git a/tests/ScheduledExecutionTest.php b/tests/ScheduledExecutionTest.php
index 76d87214..c0f07f9a 100644
--- a/tests/ScheduledExecutionTest.php
+++ b/tests/ScheduledExecutionTest.php
@@ -104,7 +104,7 @@ public function testScheduledExecutionInterval()
$actual = new DateTime($job->StartAfter);
// Allow within 1 second.
- $this->assertLessThanOrEqual(1, abs($actual->diff($expected)->s), 'Did not reschedule 1 minute later');
+ $this->assertLessThanOrEqual(1, abs($actual->diff($expected)->s ?? 0.0), 'Did not reschedule 1 minute later');
// test a custom interval of 3 minutes
@@ -121,6 +121,6 @@ public function testScheduledExecutionInterval()
$expected = new DateTime('+3 minutes');
$actual = new DateTime($job->StartAfter);
- $this->assertLessThanOrEqual(1, abs($actual->diff($expected)->s), 'Did not reschedule 3 minutes later');
+ $this->assertLessThanOrEqual(1, abs($actual->diff($expected)->s ?? 0.0), 'Did not reschedule 3 minutes later');
}
}