No Code Attached Yet bug
avatar sensomedia
sensomedia
21 Apr 2026

What happened?

  1. Go to System → Manage → Scheduled Tasks and create (or edit) any task.
  2. Set Execution Rule to Custom cron expression.
  3. In the cron-expression fields, set:
    • Minutes: 0
    • Hours: 9
    • Days of month: 1
    • Months: leave all 12 selected
    • Days of week: leave all 7 selected
  4. Save the task. The intent is: "run at 09:00 on the 1st of each month".
  5. Inspect #__scheduler_tasks.cron_rules for this row.

Version

6.1

Expected result

cron_rules.exp stores 0 9 1 * * (with * wildcards for months and days_week since all options are selected). The task runs on the 1st of each month only.

Actual result

cron_rules.exp stores 0 9 1 * 1,2,3,4,5,6,7. Because POSIX cron combines DOM and DOW with OR when both are restricted (non-wildcard), and DOW 1-7 evaluates as "every day of the week", the task runs every day at 09:00 instead of only the 1st.

System Information

  • Joomla: 5.x / 6.x (tested on 6.0)
  • PHP: 8.4
  • cron library: dragonmantank/cron-expression (bundled)

Additional Comments

Root cause

File: administrator/components/com_scheduler/src/Model/TaskModel.php, line 712 (Joomla 6.x):

$buildExpression .= ' ' . $this->wildcardIfMatch($matches['days_week'], range(0, 6), true);

The UI (administrator/components/com_scheduler/src/Field/CronField.phpOPTIONS_RANGE['days_week'] = [1, 7]) posts day-of-week values in the range 1..7 (Monday=1 to Sunday=7). The normalization call compares against range(0, 6) → the diff is never empty, so wildcardIfMatch never replaces the enumerated list with *. This is an off-by-one mismatch between UI input and normalization reference.

Impact: any task that restricts days_month will always behave as if it has no day-of-month restriction, because days_week is always a restricted enumeration.

Proposed fix

Change line 712 from range(0, 6) to range(1, 7) to match the UI values.

Alternatively, make wildcardIfMatch tolerant to both 0-based and 1-based representations of Sunday, since POSIX cron accepts both 0 and 7 for Sunday.

Workaround until fix

Manually patch cron_rules.exp in the DB after saving the task:

UPDATE #__scheduler_tasks
SET cron_rules = JSON_OBJECT('type', 'cron-expression', 'exp', '0 9 1 * *')
WHERE id = <task_id>;

Note: re-editing the task through the UI will overwrite this fix.

avatar sensomedia sensomedia - open - 21 Apr 2026
avatar sensomedia sensomedia - change - 21 Apr 2026
Labels Added: bug
avatar sensomedia sensomedia - labeled - 21 Apr 2026
avatar joomla-cms-bot joomla-cms-bot - change - 21 Apr 2026
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Apr 2026

Add a Comment

Login with GitHub to post a comment