PHP Classes

Bug report

Recommend this page to a friend!

      PHP Cron  >  All threads  >  Bug report  >  (Un) Subscribe thread alerts  
Subject:Bug report
Summary:Minor bug in PHP Cron class
Messages:6
Author:Jörg Wagner
Date:2005-09-20 20:03:11
Update:2005-09-21 18:24:48
 

  1. Bug report   Reply   Report abuse  
Picture of Jörg Wagner Jörg Wagner - 2005-09-20 20:03:11
Hello Mick,

I think I found a bug in PHP Cron:

Line 344:
$days = expand_ranges($this->bits[2]);

should read:
$days = $this->expand_ranges($this->bits[2]);

But beside that: THANKS FOR THE GOOD WORK!

Cheers, Jpsy

  2. More Bug reports   Reply   Report abuse  
Picture of Jörg Wagner Jörg Wagner - 2005-09-20 20:27:42 - In reply to message 1 from Jörg Wagner
And there seens to be more!

Trying to calculate $lastran from different crontab entries:


While...
0 0 1 9 *
works nicely:
array(6) {
[0]=> string(2) "00"
[1]=> string(2) "00"
[2]=> string(2) "01"
[3]=> string(2) "09"
[4]=> string(1) "4"
[5]=> string(4) "2005"
}


this...
0 0 1 10 *
works not:
array(1) {
[0]=> string(0) ""
}


The latter test also throws a lot of notices if they are activated in PHP, like with "ini_set('error_reporting', E_ALL);":

-----
Notice: Undefined variable: hour in D:\Backupzyklus 24x7h\webs\phpMyReminder\Cr
onParser.php on line 291

Notice: Undefined variable: minute in D:\Backupzyklus 24x7h\webs\phpMyReminder\
CronParser.php on line 291

Notice: Undefined variable: day in D:\Backupzyklus 24x7h\webs\phpMyReminder\Cro
nParser.php on line 291

Notice: Undefined variable: month in D:\Backupzyklus 24x7h\webs\phpMyReminder\C
ronParser.php on line 291

Notice: Undefined variable: year in D:\Backupzyklus 24x7h\webs\phpMyReminder\Cr
onParser.php on line 291

Notice: Undefined variable: hour in D:\Backupzyklus 24x7h\webs\phpMyReminder\Cr
onParser.php on line 292

Notice: Undefined variable: minute in D:\Backupzyklus 24x7h\webs\phpMyReminder\
CronParser.php on line 292

Notice: Undefined variable: month in D:\Backupzyklus 24x7h\webs\phpMyReminder\C
ronParser.php on line 292

Notice: Undefined variable: day in D:\Backupzyklus 24x7h\webs\phpMyReminder\Cro
nParser.php on line 292

Notice: Undefined variable: year in D:\Backupzyklus 24x7h\webs\phpMyReminder\Cr
onParser.php on line 292
-----


Sad thing! I had a lot of trouble with "pseudo-cron" which made me switch to "PHP Cron". But the cron algorithm seems to be a real beast?!

Cheers, Jpsy.

  3. Re: Bug report   Reply   Report abuse  
Picture of Mick Sear Mick Sear - 2005-09-21 07:58:27 - In reply to message 2 from Jörg Wagner
Quite true. Thanks for submitting the report. I'd not seen this because all my crons run more frequently. You need to add the following:

$year = date("Y", $this->lastRan);
$month = date("m", $this->lastRan);
$day = date("d", $this->lastRan);
$hour = date("h", $this->lastRan);
$minute = date("i", $this->lastRan);

in here:

function calcLastRan(){
$now = time();

if ($now < $this->getExtremeMonth("START")){
//The cron isn't due to have run this year yet. Getting latest last year
$this->debug("Last ran last year");
$tsLatestLastYear = $this->getExtremeMonth("END");

$this->debug("Timestamp of latest scheduled time last year is ".$tsLatestLastYear);
$this->lastRan = $tsLatestLastYear;

$year = date("Y", $this->lastRan);
$month = date("m", $this->lastRan);
$day = date("d", $this->lastRan);
$hour = date("h", $this->lastRan);
$minute = date("i", $this->lastRan);


} else {

I'm updating the class on PHPClasses. I've also fixed the first bug you've reported.

At some point, I might add support for x/n syntax, like */2 for every other day.


  4. Re: Bug report   Reply   Report abuse  
Picture of Mick Sear Mick Sear - 2005-09-21 08:21:33 - In reply to message 3 from Mick Sear
I've also fixed another bug where crons were mis-reported as not running when the first valid minute hadn't been reached in the valid current hour, so you should upgrade to the latest version.

Regards,
Mick

  5. Re: Bug report   Reply   Report abuse  
Picture of Jörg Wagner Jörg Wagner - 2005-09-21 14:31:09 - In reply to message 4 from Mick Sear
Hello Mick,

thanks for the very fast reaction! Actually I meanwhile found another PHP Cron Parser class on PHPclasses.org and inplemented it into my project. The new class is actually based on yours but was partially rewritten. The calls are still very much the same. It also supports lists and ranges, but no step values so far. If you are interested in a comparison, you can have a look at it here:
phpclasses.org/browse/package/2568. ...

Cheer, Jpsy.

  6. Re: Bug report   Reply   Report abuse  
Picture of Mick Sear Mick Sear - 2005-09-21 18:24:48 - In reply to message 5 from Jörg Wagner
Interesting! I'd not known about that class. Perhaps if I'd been alerted, I could have fixed the bugs sooner and saved you the time and bother of searching.

Cheers,
Mick