View Full Version : iGantt division by zero solution
Hi, I run into an iGantt problem, the igant.ajax.class.php file threw a division by zero warning. It should be no problem on production servers, because Warnings and Notices are hidden on those, but it can make long logfiles AND it may cause iGantt cannot render in development sites (the warning is in the ajax answer)
So the solution:
In the modules/igantt/igantt.ajax.class.php file fing the line 955:
$x += $this->_cellWidth*(($val-$this->_cellLimit[$i][0])/$this->_cellLimit[$i][1]-$this->_cellLimit[$i][0]) ;
and change to this:
$divisor = $this->_cellLimit[$i][1]-$this->_cellLimit[$i][0];
if ( $divisor != 0 ) {
$x += $this->_cellWidth*(($val-$this->_cellLimit[$i][0])/$divisor) ;
}
Hi, I run into an iGantt problem, the igant.ajax.class.php file threw a division by zero warning. It should be no problem on production servers, because Warnings and Notices are hidden on those, but it can make long logfiles AND it may cause iGantt cannot render in development sites (the warning is in the ajax answer)
So the solution:
In the modules/igantt/igantt.ajax.class.php file fing the line 955:
$x += $this->_cellWidth*(($val-$this->_cellLimit[$i][0])/$this->_cellLimit[$i][1]-$this->_cellLimit[$i][0]) ;
and change to this:
$divisor = $this->_cellLimit[$i][1]-$this->_cellLimit[$i][0];
if ( $divisor != 0 ) {
$x += $this->_cellWidth*(($val-$this->_cellLimit[$i][0])/$divisor) ;
}
Two comments :
1. you may consider upgrade to the latest version of iGantt because a similar bug has been fixed in the most recent version.
2. the code that you are hacking is not the same as in the original file (the divisor is between parenthesis because it is the UNIX time difference between two different dates that is used for interpolation). If the divisor is zero, I suspect that there is another issue somewhere else in the code.
Anyway, many thanks for your contribution.
2. the code that you are hacking is not the same as in the original file (the divisor is between parenthesis ...
I was a bit tired when I made the modification, and lazy enough to not search for the original line. The original file I was working from is "IGANTT igantt.php, v0.1.2 2009/02/10" according to the header section.
It showed me the line 955 twice (I got 2 items in the timeline).
Anyway: where can I found the patches and the new release?
Thanks!
I was a bit tired when I made the modification, and lazy enough to not search for the original line. The original file I was working from is "IGANTT igantt.php, v0.1.2 2009/02/10" according to the header section.
It showed me the line 955 twice (I got 2 items in the timeline).
Anyway: where can I found the patches and the new release?
Thanks!
Same place in sourceforge. The current version of the file is v0.1.3 2009/02/21. The most recent release also includes additional features (i.e. right click to display and update task fields manually).
CheGuevara
29-03-10, 10:17 PM
Same place in sourceforge. The current version of the file is v0.1.3 2009/02/21. The most recent release also includes additional features (i.e. right click to display and update task fields manually).
Hi Aramis
Could you post the link where the v.0.1.3 is stored?
On Sourceforge (dotproject) I've just found the v.0.1.2 version. And there on this I've got the same error as teecee posted
Thanks
Che
vBulletin® v3.6.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.