Zen Cart Logo
Forums / General Questions / PHP Fatal error: Cannot redeclare class order

PHP Fatal error: Cannot redeclare class order

Locked

Views: 4,587

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
23 Jun 2010, 7:14 PM
#1
sketchhgal avatar

sketchhgal

New Zenner

Join Date:
Aug 2007
Posts:
92
Plugin Contributions:
0

PHP Fatal error: Cannot redeclare class order

Please can someone help me with this. I've been trying to figure out why I'm getting a blank page when I click on the checkout button for my shop. I've spent days trying to work this out and I've now got the following error to come up in the error logging:

PHP Fatal error: Cannot redeclare class order in /home/lornah02/public_html/includes/classes/order.php on line 1068

I've looked at the order.php page and the only thing that is on that line is }

I've tried removing it incase this was an extra but all I acheive when I do this is the following error:

PHP Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/lornah02/public_html/includes/classes/order.php on line 1068

I know that it is difficult to offer any suggestions as to where this error is coming from without knowing all the addon's etc that are in my shop but can anyone even point me in the direction of where I should be looking or what could be wrong with the files as I have no idea. On looking at the files they appear to be correctly formatted, but I don't know if its even the orders.php file that has the error or if its somewhere else.

From everything I've read it sounds like when most people get these errors its to do with the language files but I can't see anything wrong with them.

Please can someone offer some help on this. I really don't know what to do with it now.

Any help will be greatly appreciated with this.

Thanks in advance.

23 Jun 2010, 7:36 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,690
Plugin Contributions:
56

Re: PHP Fatal error: Cannot redeclare class order

What's happening is that you have two pieces of code doing this operation:

require(DIR_WS_CLASSES . 'order.php');

To fix it, change all of these calls to

require_once(DIR_WS_CLASSES . 'order.php');

Try just changing these two files:

includes/modules/checkout_process.php
includes/modules/shipping_estimator.php

and see if that fixes it.

23 Jun 2010, 9:01 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: PHP Fatal error: Cannot redeclare class order

And, if that fixes it, then all you've done is put a bandage on a larger problem, which might be causing other more critical problems to be hidden.
You really need to find out what's causing the loop that's loading the file repeatedly.
And, yes, it's likely related to an addon, or a missing/extra file on your server, etc.
ref: http://www.zen-cart.com/wiki/index.php/Troubleshoot_-_Diagnosing_Obscure_Issues

23 Jun 2010, 9:08 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,690
Plugin Contributions:
56

Re: PHP Fatal error: Cannot redeclare class order

Wouldn't you suspect it's just a mod that has done a require when they should have done a require_once?

This certainly isn't an issue in a 1.3.8 or 1.3.9 vanilla download.

23 Jun 2010, 9:21 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: PHP Fatal error: Cannot redeclare class order

It's certainly not something related to original core code.
But I've seen cases where people have uploaded duplicate files, or renamed original files and kept the .php extension and thus caused the repeat loading of core files, or added addons that duplicated core files or did poor overrides, or where people uploaded module files into language folders thus causing modules to get "loaded" twice without obvious explanation.

Identifying all differences between original core code and what's on the live site will always help to expose what exactly is causing the problem.
This includes even renamed header_php.php files, really anything.

23 Jun 2010, 10:01 PM
#6
sketchhgal avatar

sketchhgal

New Zenner

Join Date:
Aug 2007
Posts:
92
Plugin Contributions:
0

Re: PHP Fatal error: Cannot redeclare class order

Thanks for the help on this I'll look into it and see if I can work out the problem. I'll let you know what I find.

23 Jun 2010, 11:37 PM
#7
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,690
Plugin Contributions:
56

Re: PHP Fatal error: Cannot redeclare class order

sketchgal, per Dr. Byte's suggestion, is it possible that you renamed a file

so-and-so.php

to

backup-so-and-so.php

or something like that? When renaming php files, it's best to add an extension after the .php extension, i.e.

so-and-so.php.old

especially in case the file is in a directory which is subject to automatic loading. Is it possible that this, rather than a mod, is what's causing your problem?

25 Jun 2010, 8:32 AM
#8
sketchhgal avatar

sketchhgal

New Zenner

Join Date:
Aug 2007
Posts:
92
Plugin Contributions:
0

Re: PHP Fatal error: Cannot redeclare class order

Thanks very much for all your help with this, after a few days of working through the site I've found the file that was causing the problems. swguy was correct I'd renamed a file header-BACKUP.php instead of header.php-BACKUP. Thanks for suggesting that could be causing the problem.

19 Mar 2011, 11:50 PM
#9
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,771
Plugin Contributions:
9

Re: PHP Fatal error: Cannot redeclare class order

Old post, I know, but renaming a file to something.php.old will violate one of the requirements of PCI Compliance. Leaving .zip backups, .bak, .old, .tmp, etc, leave your site vulnerable in that theses files can be downloaded and opened to reveal almost anything about your site.

Better to do what sketchhgal did, BUT, as she found out, some files are loaded just because they are in a certain directory.

If you need the files accessible on more than one machine, one solution is to create a directory like _old_files and move the original files to it. You can change the name to something like original_LanguagesEnglishCustomModulesShipping_ups.php. Lock down the directory with a 444 or similar.