PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
I'm using v. 1.3.8a with all security patches. I can't afford to upgrade to 1.3.9 right now. I just changed servers, within the same host, so they migrated everything, and all other websites are working. But the PHP version is diff. now, and all pages within the zen cart are giving a blank page, and the error reads:
PHP Fatal error: Cannot redeclare date_diff() in ...(file path) /store/includes/functions/functions_general.php on line 1476
In post http://www.zen-cart.com/forum/showthread.php?t=141937 it is recommended to install the patches available from zen cart to take care of this error message. I have replaced the file with the file in the php 5.3 patch. I'm still getting the blank page, and the same error.
This is the code in the (new) file in question, lines 1472-1479:
PHP Code:
$date1_set = mktime(0,0,0, $m1, $d1, $y1);
$date2_set = mktime(0,0,0, $m2, $d2, $y2);
return(round(($date2_set-$date1_set)/(60*60*24)));
}
/**
Does anyone see the problem???
thanks
JSC
PHP Fatal error: Cannot redeclare date_diff() in
Have had the whole PHP 5.3 answer come as the reason why the zen cart is giving blank pages, had the reply from Dr. Byte to use the patch found here
http://www.zen-cart.com/forum/showthread.php?t=140960
-- thank you Dr. Byte.
I uploaded that patch, in total, double checked all files to be sure they are the right files, and uploaded to the right directories, and the problem still exists. In the original thread I mentioned the file and line # being:
/includes/functions/functions_general.php on line 1476
I have since checked on the original file (from a backup 7 days before I replaced the files from the patch recommended by Dr. Byte) - and lines 1465 - 1480 are exactly the same. There is no difference in this file where the error log is locating a fatal error.
Could it be, there is something more needed here in this file? Or are we absolutely sure that file is fixed? I'm happy if you close this thread also Dr. Byte, but I've been using zen cart since 2006, and despite what is listed under my user name, I'm not a beginner.
thanks
JSC
Re: PHP Fatal error: Cannot redeclare date_diff() in
You REALLY need to upgrade to the latest version.
Re: PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
That's exactly what I'm going to do. :wacko:
One of those improvements (php 5.3) which comes with a pretty high price tag.
Re: PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
Quote:
One of those improvements (php 5.3) which comes with a pretty high price tag.
Well, look at it this way, 1.3.8a is not secure and 1.3.9h is secure. It just so happens that 1.3.9h works with PHP 5.3.
As for PHP 5.2, 5.3 and 6, well that's just a mess up by the PHP Project:
Normally "deprecated" means "you can use it, but it's not recommended and we will remove it in a later version" but with the step-change from 5.2 to 5.3 certain functions are deprecated but means "it's not recommended and so you can't use it".
They should have upgraded the 5.2 series, with backward compatibility, and left the major changes to the 6 series.
They certainly weren't thinking of the people who actually use PHP (hosting companies) when they made the changes the way they did. I mean by this that with cPanel it's quite easy to offer customers the choice of two major versions (4 or 5), but there's no mechanism for offering variants of the same version (5.2 and 5.3). So hosting companies have to put in place their own side-by-side solution if they want to offer the choice of 5.2 or 5.3
Vger
Re: PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
But Now I am having the problem with the PHP 5.3.6, and I have the 1.3.9h version of zencart Installed, Do you have any idea, how to fix it, Does someome knows about a patch? Please reply ASAP, I really need my admin back to work.
Re: PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
Zen Cart v1.3.9h does NOT contain any files which would trigger a "cannot redeclare date_diff()" error message.
So, your problem must exist in one of the files you've added to the site via an addon or other customization.
You will need to find the file and make whatever appropriate adjustments are needed to that file to get rid of the error.
Re: PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
Well good morning from PHP 5.3.8 vs Zen Cart 1.3.9h
PHP Fatal error: Cannot redeclare date_diff()
more specifically:
PHP Fatal error: Cannot redeclare date_diff() in /home/serveraccount/public_html/admin/includes/functions/general.php on line 3017
Hosting upgrade simultaneously wiped out my 7 instances of zen cart admin interface to white screen of death (and probably 10s of thousands of others at a guess).
Useful fix located (applied to general.php)
From this:
// compute the days between two dates
function date_diff($date1, $date2) {
//$date1 today, or any other day
//$date2 date to check against
$d1 = explode("-", $date1);
$y1 = $d1[0];
$m1 = $d1[1];
$d1 = $d1[2];
$d2 = explode("-", $date2);
$y2 = $d2[0];
$m2 = $d2[1];
$d2 = $d2[2];
$date1_set = mktime(0,0,0, $m1, $d1, $y1);
$date2_set = mktime(0,0,0, $m2, $d2, $y2);
return(round(($date2_set-$date1_set)/(60*60*24)));
}
////
To this:
// compute the days between two dates
if (! function_exists(date_diff)) {
function date_diff($date1, $date2) {
//$date1 today, or any other day
//$date2 date to check against
$d1 = explode("-", $date1);
$y1 = $d1[0];
$m1 = $d1[1];
$d1 = $d1[2];
$d2 = explode("-", $date2);
$y2 = $d2[0];
$m2 = $d2[1];
$d2 = $d2[2];
$date1_set = mktime(0,0,0, $m1, $d1, $y1);
$date2_set = mktime(0,0,0, $m2, $d2, $y2);
return(round(($date2_set-$date1_set)/(60*60*24)));
}
}
////
i.e. adding this above: if (! function_exists(date_diff)) {
and this below: }
the pre-existing code.
Anyway this fudge if that is what it is has restored all 7 instances to functionality without any ill effects so far spotted. I suspect it might be useful to others while waiting for a more official bug fix.
Re: PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
Um, there's no "bug fix" required except to say you're using old code.
See my last post.
V1.3.9 doesn't contain a "date_diff" function, because it was renamed to zen_date_diff.
Evidently your site needs an upgrade, not a bug fix.
Re: PHP ver. 5.3 -PHP Fatal error: Cannot redeclare date_diff() in
Sir, in that case I am confused. Every instance of Zen Cart I have started life as a native 1.3.9h clean install, however most of what I have now is profoundly modified. i.e. another clean install of 1.3.9h is no longer a viable option.
If I have to assume that somewhere along that journey a module has overwritten admin/includes/general.php (or something else that can throw an error in that code) please will you advise whether what I have done with this
if (! function_exists(date_diff)) { } in general.php
is a genuine solution, or what exactly I should searching for, deleting or replacing it with in the code overall to restore the 1.3.9h state for this affected function.
I have noticed that you are not in the habit of spoon feeding rounded solutions however in this case I trust you will yield as I am concerned that I and others who are in the dark on this one may well have compromised security without realizing it - and in my case at least, I have to assume that I have defeated date_diff and am lacking the zen_date_diff function entirely with unknown consequences likely to ensue.
Thank you