Skip to content

Commit

Permalink
API Deprecate API that will be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 10, 2024
1 parent edbda80 commit 0953b95
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions src/Task/StaticCacheFullBuildTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\StaticPublishQueue\Job\StaticCacheFullBuildJob;
Expand Down Expand Up @@ -42,12 +43,14 @@ public function run($request)
$existing = DataList::create(QueuedJobDescriptor::class)->filter($filter)->first();

if ($existing && $existing->exists()) {
$this->log(sprintf(
'There is already a %s in the queue, added %s %s',
StaticCacheFullBuildJob::class,
$existing->Created,
$existing->StartAfter ? 'and set to start after ' . $existing->StartAfter : ''
));
Deprecation::withNoReplacement(function () use ($existing) {
$this->log(sprintf(
'There is already a %s in the queue, added %s %s',
StaticCacheFullBuildJob::class,
$existing->Created,
$existing->StartAfter ? 'and set to start after ' . $existing->StartAfter : ''
));
});

return false;
}
Expand All @@ -71,20 +74,26 @@ public function run($request)

// sanity check that we are in the next 24 hours - prevents some weird stuff sneaking through
if ($startAfter->getTimestamp() > $thisTimeTomorrow || $startAfter->getTimestamp() < $now->getTimestamp()) {
$this->log('Invalid startAfter parameter passed. Please ensure the time format is HHmm e.g. 1300');
Deprecation::withNoReplacement(function () {
$this->log('Invalid startAfter parameter passed. Please ensure the time format is HHmm e.g. 1300');
});

return false;
}

$this->log(sprintf(
'%s queued for %s %s.',
StaticCacheFullBuildJob::class,
$startAfter->format('H:m'),
$dayWord
));
Deprecation::withNoReplacement(function () use ($startAfter, $dayWord) {
$this->log(sprintf(
'%s queued for %s %s.',
StaticCacheFullBuildJob::class,
$startAfter->format('H:m'),
$dayWord
));
});
} else {
$startAfter = null;
$this->log(StaticCacheFullBuildJob::class . ' added to the queue for immediate processing');
Deprecation::withNoReplacement(function () {
$this->log(StaticCacheFullBuildJob::class . ' added to the queue for immediate processing');
});
}

$job->setJobData(0, 0, false, new \stdClass(), [
Expand All @@ -95,8 +104,12 @@ public function run($request)
return true;
}

/**
* @deprecated 6.3.0 Will be removed without equivalent functionality to replace it
*/
protected function log($message)
{
Deprecation::notice('6.3.0', 'Will be removed without equivalent functionality to replace it');
$newLine = Director::is_cli() ? PHP_EOL : '<br>';
echo $message . $newLine;
}
Expand Down

0 comments on commit 0953b95

Please sign in to comment.