Skip to content

Commit 3245fcd

Browse files
committed
Do not display an error message if the cronjob is already disabled/enabled and this status is to be changed to that status.
1 parent 2790163 commit 3245fcd

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/DisableCronjob.class.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
3131

3232
$this->assertCronjobCanBeDisabled($cronjob);
3333

34-
(new CronjobAction([$cronjob], 'toggle'))->executeAction();
34+
if (!$cronjob->isDisabled) {
35+
(new CronjobAction([$cronjob], 'toggle'))->executeAction();
36+
}
3537

3638
return new JsonResponse([]);
3739
}
@@ -40,11 +42,7 @@ private function assertCronjobCanBeDisabled(Cronjob $cronjob): void
4042
{
4143
WCF::getSession()->checkPermissions(['admin.management.canManageCronjob']);
4244

43-
if ($cronjob->canBeDisabled()) {
44-
throw new PermissionDeniedException();
45-
}
46-
47-
if ($cronjob->isDisabled) {
45+
if (!$cronjob->canBeDisabled()) {
4846
throw new PermissionDeniedException();
4947
}
5048
}

wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/EnableCronjob.class.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
3131

3232
$this->assertCronjobCanBeEnabled($cronjob);
3333

34-
(new CronjobAction([$cronjob], 'toggle'))->executeAction();
34+
if ($cronjob->isDisabled) {
35+
(new CronjobAction([$cronjob], 'toggle'))->executeAction();
36+
}
3537

3638
return new JsonResponse([]);
3739
}
@@ -40,11 +42,7 @@ private function assertCronjobCanBeEnabled(Cronjob $cronjob): void
4042
{
4143
WCF::getSession()->checkPermissions(['admin.management.canManageCronjob']);
4244

43-
if ($cronjob->canBeDisabled()) {
44-
throw new PermissionDeniedException();
45-
}
46-
47-
if (!$cronjob->isDisabled) {
45+
if (!$cronjob->canBeDisabled()) {
4846
throw new PermissionDeniedException();
4947
}
5048
}

0 commit comments

Comments
 (0)