Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
wazum wants to merge1 commit intosymfony:6.4
base:6.4
Choose a base branch
Loading
fromwazum:fix-recurring-message-last-day-60745

Conversation

wazum
Copy link
Contributor

@wazumwazum commentedJul 17, 2025
edited
Loading

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#60745
LicenseMIT

Issue

When usingRecurringMessage::every() with comma-separated weekdays like"Monday, Thursday, Saturday", the scheduler silently fails because PHP'sDateInterval::createFromDateString() treats commas as delimiters, not processing the list as intended.

Solution

I have done a detailed analysis and searched the PHP documentation. Comma-separated weekday strings are not officially supported by PHP's DateInterval::createFromDateString() method. The PHP manual does not document this format, and testing confirms that commas act as delimiters in the date parsing engine, causing unexpected behavior.

Added validation to detect comma-separated values in PeriodicalTrigger and throw a clear InvalidArgumentException instead of allowing silent failures.

Changes

  • Added comma detection check in PeriodicalTrigger::__construct()
  • Added test case in PeriodicalTriggerTest::getInvalidIntervals()
  • Clear error message guides users to use cron expressions for multiple weekdays

Alternative: For multiple weekdays, useRecurringMessage::cron('5 12 * * 1,4,6', $message, 'Europe/Warsaw') instead.

Documentation

Update is here:symfony/symfony-docs#21212

@@ -51,6 +51,10 @@ public function __construct(

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

@nicolas-grekasnicolas-grekasJul 17, 2025
edited
Loading

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
ContributorAuthor

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.

@carsonbotcarsonbot changed the titleAdd validation for comma-separated weekdays in PeriodicalTrigger[Scheduler] Add validation for comma-separated weekdays in PeriodicalTriggerJul 17, 2025
@symfonysymfony deleted a comment fromcarsonbotJul 17, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@kbondkbondAwaiting requested review from kbondkbond is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

3 participants
@wazum@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp