Skip to content

[Scheduler] Add validation for comma-separated weekdays in PeriodicalTrigger #61143

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

Open
wants to merge 1 commit into
base: 6.4
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public static function getInvalidIntervals(): iterable
yield [-3600, 'The "$interval" argument must be greater than zero.'];
yield ['0', 'The "$interval" argument must be greater than zero.'];
yield [0, 'The "$interval" argument must be greater than zero.'];
yield ['Monday, Thursday, Saturday', 'Comma-separated values are not supported'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public function __construct(

$i = $interval;
if (\is_string($interval)) {
if (str_contains($interval, ',')) {
Copy link
Member

@nicolas-grekas nicolas-grekas Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this might be too specific.

What about this instead?

--- a/src/Symfony/Component/Scheduler/Trigger/PeriodicalTrigger.php
+++ b/src/Symfony/Component/Scheduler/Trigger/PeriodicalTrigger.php
@@ -117,6 +117,10 @@ class PeriodicalTrigger implements StatefulTriggerInterface
             }
         }
 
+        if ($next == $run) {
+            throw new InvalidArgumentException(\sprintf('Invalid interval "%s".', $this->description));
+        }
+
         return $next;
     }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas You are right. I don't think this can be solved at the moment.
I have been working on it for hours now, also with the PHP parser. The underlying problem lies with PHP. Commas is too specific (we would have the same problem with spaces).

I have made a pull request for the documentation, which has already been merged.
Is this a solution that is OK for this problem (via a note in the documentation)?
Developers may continue to define invalid intervals without getting an error.

throw new InvalidArgumentException(\sprintf('Invalid interval "%s": Comma-separated values are not supported', $interval));
}

$this->description = \sprintf('every %s', $interval);
$i = @\DateInterval::createFromDateString($interval);

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy