Fixed bug #16321: [scheduler] Numeric zero for representation of weekday sunday is...
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 26 Nov 2010 21:00:00 +0000 (21:00 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 26 Nov 2010 21:00:00 +0000 (21:00 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-3@9658 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/scheduler/class.tx_scheduler_croncmd.php

index 09f319c..e22d6db 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 
 2010-11-26  Christian Kuhn  <lolli@schwarzbu.ch>
 
+       * Fixed bug #16321: [scheduler] Numeric zero for representation of weekday sunday is not accepted (Thanks to Marcus Krause)
        * Fixed bug #16582: [Caching framework] Remove misleading memcached configuration example from config_default
        * Fixed bug #16317: [scheduler] Valid values generated from cron command does not contain integers only (Thanks to Marcus Krause)
 
index c11501a..dbf6868 100644 (file)
@@ -192,16 +192,23 @@ class tx_scheduler_CronCmd {
                        // Consider special field 'day of week'
                        // @TODO: Implement lists and ranges for day of week (2,3 and 1-5 and */2,3 and 1,1-5/2)
                        // @TODO: Support usage of day names in day of week field ("mon", "sun", etc.)
-               if ((strpos($this->cmd_sections[4], '*') === FALSE && preg_match('/[1-7]{1}/', $this->cmd_sections[4]) !== FALSE)) {
+               if ((strpos($this->cmd_sections[4], '*') === FALSE && preg_match('/[0-7]{1}/', $this->cmd_sections[4]) !== FALSE)) {
                                // Unset days from 'day of month' if * is given
                                // * * * * 1 results to every monday of this month
                                // * * 1,2 * 1 results to every monday, plus first and second day of month
                        if ($this->cmd_sections[2] == '*') {
                                $validDays = array();
                        }
+
+                               // Allow 0 as representation for sunday and convert to 7
+                       $dayOfWeek = $this->cmd_sections[4];
+                       if ($dayOfWeek === '0') {
+                               $dayOfWeek = '7';
+                       }
+
                                // Get list
                        for ($i = 1; $i <= $max_days; $i++) {
-                               if (strftime('%u', mktime(0, 0, 0, $currentMonth, $i, $currentYear)) == $this->cmd_sections[4]) {
+                               if (strftime('%u', mktime(0, 0, 0, $currentMonth, $i, $currentYear)) == $dayOfWeek) {
                                        if (!in_array($i, $validDays)) {
                                                $validDays[] = $i;
                                        }