feat(scheduler): delete orphaned jobs and block editing of unregistered jobs
Adds deleteOrphanedJobs() to clean up stale job_keys during ensureSystemJobs, and prevents editing jobs that are no longer registered in the runtime registry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,8 @@ if (!$job) {
|
||||
Router::redirect('admin/scheduled-jobs');
|
||||
}
|
||||
|
||||
$isRegistered = $scheduledJobService->isRegistered((string) ($job['job_key'] ?? ''));
|
||||
|
||||
$currentUserId = (int) ($session['user']['id'] ?? 0);
|
||||
$authorizationService = app(\MintyPHP\Service\Access\AuthorizationService::class);
|
||||
$canManage = $authorizationService->authorize(\MintyPHP\Service\Access\OperationsAuthorizationPolicy::ABILITY_ADMIN_JOBS_MANAGE, [
|
||||
@@ -39,6 +41,12 @@ $form = [
|
||||
];
|
||||
$errorBag = formErrors();
|
||||
|
||||
if (!$isRegistered) {
|
||||
$canManage = false;
|
||||
$canRunNow = false;
|
||||
$errorBag->addGlobal(t('This scheduled job is no longer registered and cannot be edited. It has been superseded by a newer version.'));
|
||||
}
|
||||
|
||||
if (requestInput()->method() === 'POST') {
|
||||
if (!$canManage) {
|
||||
Guard::deny();
|
||||
|
||||
Reference in New Issue
Block a user