Forums / Upgrading to 1.5.x / Cannot redeclare class QueryCache ... on line 16

Cannot redeclare class QueryCache ... on line 16

Views: 1,942

Results 1 to 20 of 20
31 Jul 2014, 4:08 PM
#1
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Cannot redeclare class QueryCache ... on line 16

I have just upgraded from 1.5.1 to 1.5.3. Everything went well I thought, but after the database upgrade I am getting blanks pages on my website and admin page. I checked the logs and this is what I'm getting.

PHP Fatal error: Cannot redeclare class QueryCache in /home/xxxxxx/public_html/includes/classes/query_cache.php on line 16

When I check line 16 of query_cache.php this is whats on it.

class QueryCache {

I thought I would try to upgrade the database again, but when I run zc_install all I get now is install button no upgrade. My site is https://www.countryhomemade.com

Thanks,
Randy

31 Jul 2014, 4:42 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Cannot redeclare class QueryCache ... on line 16

You've got leftover files from having installed the old query-cache addon, including in the /includes/auto_loaders and /includes/init_includes folders.
Part of upgrading is removing files that no longer belong.

See same discussion here: http://www.zen-cart.com/showthread.php?200507&p=1252800#post1252800

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

31 Jul 2014, 4:47 PM
#3
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Cannot redeclare class QueryCache ... on line 16

rtfulk:

... Cannot redeclare class QueryCache in /home/xxxxxx/public_html/includes/classes/query_cache.php ...
Typically indicates some leftover files from a previous install. Can you try the following:

  1. Log into your Zen Cart administrative interface.
  2. Select "Tools" -> "Developers Tool Kit" from the top menu.
  3. Scroll down to "lookup in all files".
  4. Enter "QueryCache" for the "Key or Name:".
  5. Leave "All Files Look-ups:" set to "All Files - Catalog/Admin".
  6. Leave "File type:" set to ".php only".
  7. Click the search button to the right.
    This should help locate where the leftover file causing the QueryCache to be loaded twice is located.

Did you know you can search the Zen Cart site using a search engine by using keywords and adding site:zen-cart.com to your search? I personally find this method of searching effective.

NOTE: Beaten to the answer by DrByte while typing :)

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

31 Jul 2014, 4:50 PM
#4
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Cannot redeclare class QueryCache ... on line 16

rtfulk:

I have just upgraded from 1.5.1 to 1.5.3. Everything went well I thought, but after the database upgrade I am getting blanks pages on my website and admin page. I checked the logs and this is what I'm getting.

PHP Fatal error: Cannot redeclare class QueryCache in /home/xxxxxx/public_html/includes/classes/query_cache.php on line 16

I think the database upgrade aspect may be a bit of a red herring. The PHP error is related to the files, not the database.

rtfulk:

When I check line 16 of query_cache.php this is whats on it.

class QueryCache {

This is what I would be expecting to find here (based on the error message).

rtfulk:

I thought I would try to upgrade the database again, but when I run zc_install all I get now is install button no upgrade. My site is www.countryhomemade.com

Step away from the database for the time being.

What the error message is telling us is "Line #16 of query_cache.php needs to create a 'class' called 'QueryCache' but I can't do this because a class of this name has already been created".

In other words, the message itself isn't particularly helpful because it doesn't tell us where the 'class' was previously declared, so that's really the 1st thing you need to find out.

There aren't many possible causes of classes to be redeclared, and probably the most common cause is because a backup file declaring the same class exists in the same folder as the original file. There are other reasons, but the bottom line is, you have somehow got two different files that both contain a line that reads

"class QueryCache {"

So, the easiest way to tackle this problem is to use the ZenCart Developers Toolkit and perform a case sensitive search on all the .php files for "QueryCache".

On a 'good' system (V1.5.3) there will be a total of four matches, in two different files.

**/includes/auto_loaders/config.core.php
**Line #76 : 'className'=>'QueryCache',

and
**/includes/classes/query_cache.php
**Line #13 : * QueryCache
Line #16 : class QueryCache {
Line #18 : function QueryCache() {

If you find any other files that match the 1st thing to do is rename them so they don't have a .php filename extension (especially if they appear to be a backup file). This is all you will probably need to do to take care of the error being reported. If this is the only error on the site you'll probably find it'll just spring back to life. If it doesn't you'll probably find a different error is now being reported.

I would suggest that when you get to this point that you come back here and report on your findings in regards to the possible duplicated/backup file as well as reporting any further error messages. Avoid the temptation to go any further yourself (unless confident with what you are doing), because the last thing we need at this stage is the possibility of compounding the problem.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

31 Jul 2014, 5:19 PM
#5
drbyte avatar

drbyte

Sensei

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

Re: Cannot redeclare class QueryCache ... on line 16

RodG:

So, the easiest way to tackle this problem is to use the ZenCart Developers Toolkit and perform a ...
I was going to suggest that too ... but then I remembered that they can't access their Admin:
rtfulk:

... I am getting blanks pages on my website and admin page.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

31 Jul 2014, 5:28 PM
#6
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Cannot redeclare class QueryCache ... on line 16

DrByte:

I was going to suggest that too ... but then I remembered that they can't access their Admin:

:blush::blush::blush: Oh yeah. That would make this suggestion a little difficult wouldn't it.

Time for bed. Brain ceased to function.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

31 Jul 2014, 5:43 PM
#7
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Cannot redeclare class QueryCache ... on line 16

DrByte:

I was going to suggest that too ... but then I remembered that they can't access their Admin:
:blush: Yup, missed this...

Although a bit strange as QueryCache is not typically loaded (out of box) when accessing the Zen Cart administrative interface... Perhaps some files were accidentally uploaded / merged in the wrong locations (catalog versus admin)?

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

31 Jul 2014, 5:49 PM
#8
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

Thanks for all the suggestions, unfortunately I don't have access to the admin area.

DrByte, I took your suggestion and looked at the 2 folders.
/includes/autoloader had 2 files dated back to 1.5.1 config.query_cache.php and nochex_apc.core.php
/includes/init_includes folders had on file dated back to 1.5.1 init_nochex_apc_sessions.php

Instead of deleting them right now I just renamed with a .bak extension. Now on the web page I get this
Sorry!
There seems to be a problem connecting to our database. Please give us a few minutes to remedy the problem. Thank you.
To verify the site status click here.

When I click it nothing happens.

My question is: Am I on the right track and also should there be any files dated back to 1.5.1 version?

31 Jul 2014, 6:00 PM
#9
drbyte avatar

drbyte

Sensei

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

Re: Cannot redeclare class QueryCache ... on line 16

rtfulk:

DrByte, I took your suggestion and looked at the 2 folders.
/includes/autoloader had 2 files dated back to 1.5.1 config.query_cache.php and nochex_apc.core.php
/includes/init_includes folders had on file dated back to 1.5.1 init_nochex_apc_sessions.php

Instead of deleting them right now I just renamed with a .bak extension.Good :)
Yes, you're on the right track.

rtfulk:

Now on the web page I get this
Sorry!
There seems to be a problem connecting to our database. Please give us a few minutes to remedy the problem. Thank you.
To verify the site status click here.
That indicates that the db can't be connected. Specifically, when using the credentials in your admin configure.php the database isn't responding.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

31 Jul 2014, 6:03 PM
#10
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

One other question I noticed the stylesheet.css and stylesheet_css_buttons.css were updated. I have my own template folder should I merge those 2 css files to my template css files?

31 Jul 2014, 6:06 PM
#11
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

DrByte:

Good :)
Yes, you're on the right track.

That indicates that the db can't be connected. Specifically, when using the credentials in your admin configure.php the database isn't responding.

I have checked and double checked the Database username and password just to make sure everything is correct.

31 Jul 2014, 7:41 PM
#12
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

Can this be done? Since the database has been updated to 1.5.3. Can I upload the files from 1.5.3 and copy my configure.php files and my custom template over? I only have a couple of mods installed .

31 Jul 2014, 11:55 PM
#13
drbyte avatar

drbyte

Sensei

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

Re: Cannot redeclare class QueryCache ... on line 16

rtfulk:

Can this be done? Since the database has been updated to 1.5.3. Can I upload the files from 1.5.3 and copy my configure.php files and my custom template over? I only have a couple of mods installed .
Yes, and that's essentially what I usually do when upgrading anyway ... my process is described here: http://www.zen-cart.com/entry.php?3-How-do-I-rebuild-my-site-on-the-new-version-instead-of-upgrading

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

31 Jul 2014, 11:56 PM
#14
drbyte avatar

drbyte

Sensei

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

Re: Cannot redeclare class QueryCache ... on line 16

rtfulk:

One other question I noticed the stylesheet.css and stylesheet_css_buttons.css were updated. I have my own template folder should I merge those 2 css files to my template css files?

You can certainly compare those files with the same files from the prior version (WinMerge is handy for this) and then make the corresponding updates in your own template.
In fact, that's what upgrading is about.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Aug 2014, 6:59 AM
#15
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

Thanks for all the help. I have reverted back to 1.5.1 for now. I have ran into one issue The admin area loads now, but the webpage is still blank. Any suggestions?

I have setup a test site and database for 1.5.3 and it is running just the generic Zen Cart stuff right now after I get the site back up I can start working on incorporating my live site into it.

Thanks,
Randy

1 Aug 2014, 11:25 AM
#16
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Cannot redeclare class QueryCache ... on line 16

"webpage blank" means that you've got a debug-log file in your /logs folder. Since it's an admin-related log (the characters -adm- will appear in the filename), make sure to obfuscate your admin-folder's name if/when you post its contents.

1 Aug 2014, 5:10 PM
#17
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

The latest error in the log files for admin was from 3 days ago (before I started the upgrade). I was a ZEND error php was changed to 5.4 and should have been 5.2. That has been corrected.

1 Aug 2014, 6:29 PM
#18
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

With the database being updated to 1.5.3 and I'm running 1.5.1 that should be an issue should it?

1 Aug 2014, 6:33 PM
#19
drbyte avatar

drbyte

Sensei

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

Re: Cannot redeclare class QueryCache ... on line 16

rtfulk:

With the database being updated to 1.5.3 and I'm running 1.5.1 that should be an issue should it?

It is normally not recommended; however, in the case of running v1.5.1 against a v1.5.3 database, there should be no problem ... with one exception: any customer or administrator passwords that were automatically updated to more secure formats will no longer work if you're using v1.5.1.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Aug 2014, 6:55 PM
#20
rtfulk avatar

rtfulk

New Zenner

Join Date:
Jan 2006
Posts:
42
Plugin Contributions:
0

Re: Cannot redeclare class QueryCache ... on line 16

Update.

First I want to thank everyone for their suggestions and help. Everything is back up and running. I wish I could be more specific in what I done to get it back up and running, but this is what got my website back up.

I started at the beginning I downloaded a fresh copy of 1.5.1 and started comparing and uploading files in the includes folder after each file I checked the website. I got lucky the auto_loader folder had the problem in it. I don't know which file it was since I uploaded the folder completely.

Even though this is a vague answer, I hope it can help someone else that has encountered the blank page problem.

Thanks,
Randy