Project

General

Profile

Actions

Bug #25676

closed

miscalculation in the scheduler at the turn of the year 2010 => 2011

Added by Administrator Admin over 13 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Category:
scheduler
Target version:
-
Start date:
2010-11-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hi,

can anyone confirm that there is a miscalculation in the scheduler at the turn of the year?

Following cronentry: 31 2 * * 1

Send mail at every monday at 2:31

Last Execution Time: 27.12.2010 2:31
Next Execution Time: 10.1.2011 2:31

In 2011 the first Monday is on 3.1.2011

Greetings

(issue imported from #M16470)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #25677: tx_scheduler_CronCmd needs refactoringClosedChristian Kuhn2010-11-29

Actions
Actions #1

Updated by Administrator Admin over 13 years ago

code example for this bug:

$cronCmd = new tx_scheduler_CronCmd('31 2 * * 1', mktime(10,0,0,12,28,2010));
$cronCmd->calculateNextValue(0);
$tstamp = $cronCmd->getTstamp();

echo strftime('%Y-%m-%d', $tstamp);

-> outputs 2011-01-10 (should output 2011-01-03)

Actions #2

Updated by Tobias Hoevelborn over 13 years ago

Hi,
can confirm, calculateNextValue seems to be the problem, indeed.

In case no next_value can be found for the current level, the second 'for' loop resets the higher levels until a level is reached where a valid next value (aka increased_value) is found.

If the month level is reached and no increased value ist found (as in the given example), the month value will be set to start value, the valid values for day level will be recalculetd, but no new start day value will be set (happening in the else branch of the unpatched code).

In order to not repeat to much code I didn't copy the setting of valid day start value into the else branch but rather dropped the whole check there and changes the if condition to recalculate day level if the value on year level has been increased.

(see patch attached)

The whole method using recursion and two loops to traverse the date levels is pretty hard to read and understand (at least for me ;-)). Perhaps it schould be rewritten and simplefied some day?

regards, Tobias

Actions #3

Updated by Francois Suter over 13 years ago

Committed v3 to 4.3 in revision 9826
Committed v3 to 4.4 in revision 9827, with the proposed unit tests.

Actions #4

Updated by Francois Suter almost 12 years ago

  • Status changed from Resolved to Closed
Actions #5

Updated by Michael Stucki over 10 years ago

  • Category set to scheduler
Actions #6

Updated by Michael Stucki over 10 years ago

  • Project changed from 739 to TYPO3 Core
  • Category changed from scheduler to scheduler
  • Target version deleted (0)
Actions

Also available in: Atom PDF