Skip to content

Commit

Permalink
ENH Add generic types (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 23, 2024
1 parent b552916 commit 9cf0162
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/Extensions/MaintenanceLockExtension.php
Expand Up @@ -12,8 +12,9 @@
* Class MaintenanceLockExtension
* Adds a maintenance lock UI to SiteConfig
*
* @property SiteConfig|$this owner
* @package Symbiote\QueuedJobs\Extensions
*
* @extends DataExtension<SiteConfig&static>
*/
class MaintenanceLockExtension extends DataExtension
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/ScheduledExecutionExtension.php
Expand Up @@ -10,6 +10,7 @@
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBDatetime;
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
use Symbiote\QueuedJobs\Jobs\ScheduledExecutionJob;
Expand All @@ -23,7 +24,10 @@
*
* @author marcus@symbiote.com.au
* @license BSD License http://silverstripe.org/bsd-license/
*
* @method QueuedJobDescriptor ScheduledJob()
*
* @extends DataExtension<DataObject&static>
*/
class ScheduledExecutionExtension extends DataExtension
{
Expand Down
11 changes: 1 addition & 10 deletions src/Services/QueuedJobService.php
Expand Up @@ -402,15 +402,13 @@ public function getNextPendingJob($type = null)
->sort('ID', 'ASC');

// see if there's any blocked jobs that need to be resumed
/** @var QueuedJobDescriptor $waitingJob */
$waitingJob = $list->find('JobStatus', QueuedJob::STATUS_WAIT);

if ($waitingJob) {
return $waitingJob;
}

// Otherwise, lets find any 'new' jobs that are waiting to execute
/** @var QueuedJobDescriptor $newJob */
$newJob = $list
->filter('JobStatus', QueuedJob::STATUS_NEW)
->where(sprintf(
Expand Down Expand Up @@ -468,7 +466,6 @@ public function checkJobHealth($queue = null)
'"Expiry" IS NULL AND "LastEdited" <= ?' => $this->getInitStateExpiry()
]);

/** @var QueuedJobDescriptor $stalledJob */
foreach ($stalledJobs as $stalledJob) {
$jobClass = $stalledJob->Implementation;

Expand All @@ -492,7 +489,6 @@ public function checkJobHealth($queue = null)
// now, find those that need to be marked before the next check
// foreach job, mark it as having been incremented
foreach ($runningJobs as $job) {
/** @var QueuedJobDescriptor $job */
$job->LastProcessedCount = $job->StepsProcessed;
$job->write();
}
Expand Down Expand Up @@ -752,7 +748,6 @@ protected function grabMutex(QueuedJobDescriptor $jobDescriptor)
Convert::raw2sql($descriptorId)
));

/** @var QueuedJobDescriptor $updatedDescriptor */
$updatedDescriptor = QueuedJobDescriptor::get()->byID($descriptorId);

// If we couldn't find the descriptor or the descriptor is not the one we expect to have
Expand Down Expand Up @@ -800,7 +795,6 @@ public function runJob($jobId)
$logger = $this->getLogger();

// first retrieve the descriptor
/** @var QueuedJobDescriptor $jobDescriptor */
$jobDescriptor = DataObject::get_by_id(
QueuedJobDescriptor::class,
(int)$jobId
Expand All @@ -817,7 +811,6 @@ public function runJob($jobId)
// We need to use $_SESSION directly because SS ties the session to a controller that no longer exists at
// this point of execution in some circumstances
$originalUserID = isset($_SESSION['loggedInAs']) ? $_SESSION['loggedInAs'] : 0;
/** @var Member|null $originalUser */
$originalUser = $originalUserID
? DataObject::get_by_id(Member::class, $originalUserID)
: null;
Expand Down Expand Up @@ -869,7 +862,6 @@ public function runJob($jobId)
Subsite::changeSubsite($job->SubsiteID);

// lets set the base URL as far as Director is concerned so that our URLs are correct
/** @var Subsite $subsite */
$subsite = DataObject::get_by_id(Subsite::class, $job->SubsiteID);
if ($subsite && $subsite->exists()) {
$domain = $subsite->domain();
Expand All @@ -882,7 +874,6 @@ public function runJob($jobId)
// while not finished
while (!$job->jobFinished() && !$broken) {
// see that we haven't been set to 'paused' or otherwise by another process
/** @var QueuedJobDescriptor $jobDescriptor */
$jobDescriptor = DataObject::get_by_id(
QueuedJobDescriptor::class,
(int)$jobId
Expand Down Expand Up @@ -1282,7 +1273,7 @@ protected function humanReadable($size)
* The number of seconds to include jobs that have just finished, allowing a job list to be built that
* includes recently finished jobs
*
* @return DataList|QueuedJobDescriptor[]
* @return DataList<QueuedJobDescriptor>
*/
public function getJobList($type = null, $includeUpUntil = 0)
{
Expand Down
1 change: 0 additions & 1 deletion src/Tasks/Engines/DoormanRunner.php
Expand Up @@ -89,7 +89,6 @@ public function runQueue($queue)

// split jobs out into multiple tasks...

/** @var ProcessManager $manager */
$manager = Injector::inst()->create(ProcessManager::class);
$manager->setWorker(
sprintf(
Expand Down

0 comments on commit 9cf0162

Please sign in to comment.