Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Jan 2006
    Posts
    42
    Plugin Contributions
    0

    Default 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 www.countryhomemade.com


    Thanks,
    Randy

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default 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.p...00#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.

  3. #3
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: Blank pages on website and admin page.

    Quote Originally Posted by rtfulk View Post
    ... 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 :)
    Last edited by lhungil; 31 Jul 2014 at 05:49 PM.
    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

  4. #4
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

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

    Quote Originally Posted by rtfulk View Post
    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.

    Quote Originally Posted by rtfulk View Post
    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).

    Quote Originally Posted by rtfulk View Post
    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






  5. #5
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

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

    Quote Originally Posted by RodG View Post
    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:
    Quote Originally Posted by rtfulk View Post
    ... 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.

  6. #6
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

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

    Quote Originally Posted by DrByte View Post
    I was going to suggest that too ... but then I remembered that they can't access their Admin:
    Oh yeah. That would make this suggestion a little difficult wouldn't it.

    Time for bed. Brain ceased to function.

    Cheers
    RodG

  7. #7
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

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

    Quote Originally Posted by DrByte View Post
    I was going to suggest that too ... but then I remembered that they can't access their Admin:
    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

  8. #8
    Join Date
    Jan 2006
    Posts
    42
    Plugin Contributions
    0

    Default 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?

  9. #9
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

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

    Quote Originally Posted by rtfulk View Post
    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.

    Quote Originally Posted by rtfulk View Post
    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.

  10. #10
    Join Date
    Jan 2006
    Posts
    42
    Plugin Contributions
    0

    Default 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?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Fatal error Cannot redeclare class
    By sasha21 in forum General Questions
    Replies: 5
    Last Post: 21 Jul 2013, 03:21 AM
  2. Replies: 3
    Last Post: 3 Aug 2009, 06:13 AM
  3. cannot redeclare class base...
    By awhitley2 in forum General Questions
    Replies: 3
    Last Post: 23 Jun 2009, 02:02 PM
  4. Cannot redeclare class
    By (Deus) in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 2 Feb 2007, 06:31 AM
  5. Cannot redeclare class ot_coupon in
    By vixenz in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 16 Aug 2006, 09:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg