PHP Classes

tdCron: Wrong Comparison on FALSE Value

Recommend this page to a friend!

      tdCron  >  All threads  >  tdCron: Wrong Comparison on FALSE Value  >  (Un) Subscribe thread alerts  
Subject:tdCron: Wrong Comparison on FALSE Value
Summary:Bug Fix
Messages:1
Author:Fish Drowned
Date:2012-07-04 11:42:22
 

  1. tdCron: Wrong Comparison on FALSE Value   Reply   Report abuse  
Picture of Fish Drowned Fish Drowned - 2012-07-04 11:42:22
I would like to express my thanks to your parser, it's great, easy to use, and running efficiently!

But... there's a bug in the parser, which confused me for days, I've setup a cron job at 0:10 every night, but it was never executed so far.

===========================
How to reproduce:
Try test data:

$tests[] = array(
'desc' => '2012-7-4 0:10',
'expression' => '10 0 * * *',
'reftime' => mktime(0,9,30,7,4,2012),
'expected_l' => '03.07.2012, 00:10:00',
'expected_n' => '04.07.2012, 00:10:00'
);

And the result will be:
Expression: [10 0 * * *]
Ref-Time: [04.07.2012, 00:09:30]

nextRun(): [05.07.2012, 00:10:00]
Expected: [04.07.2012, 00:10:00] - FAILED!

===========================
How to resolve:
class.tdcron.php line 161:

if (!$nhour) {

!$nhour is not safe for 0. It should be:

if ($nhour === FALSE) {

===========================
This time I got the expected result:
nextRun(): [04.07.2012, 00:10:00]
Expected: [04.07.2012, 00:10:00] - passed!

Cheers!