Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #415

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Extensions/MaintenanceLockExtension.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 [email protected]
* @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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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