Title: Cannot declare class WP_Object_Cache,
Last modified: October 2, 2024

---

# Cannot declare class WP_Object_Cache,

 *  Resolved [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/)
 * Hello,
 * I have this error that just appeared and causes the site to brake.
 * `[02-Oct-2024 10:33:40 UTC] PHP Fatal error: Cannot declare class WP_Object_Cache,
   because the name is already in use in .../wp-content/plugins/apcu-manager/includes/
   api/object-class.php on line 18`
 * The issue appeared after I fixed something in an override where we kept on using
   $product->id instead of $product->get_id(); That’s not really related I guess
   but I think it blocked the error before and right after I fixed it, the WP_Object_Cache
   appeared.
   I deactivated the apcu manager plugin in the meantime. Any idea what
   causes this ? I thought it could be because of another cache plugin but I have
   only one (Cloudfare) and tried to deactivate it but it doesn’t change anything.
   Thank you

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18049967)
 * Hello [@hellodracon](https://wordpress.org/support/users/hellodracon/) !
 * Sorry to hear that…
 * You’re definitely right: it can come from another object cache plugin which is
   called directly and before WordPress load the `object-cache.php` file. To be 
   honest, I have no idea how such a case could arise.
 * Do you have other issues with your site that can be linked (or not)?
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18050091)
 * Hello Pierre and thank you for answering that quick.
   I don’t think there’s other
   issues linked to this. The only thing I see in the debug.log is this error again
   and again (yet I wasn’t seing this error before fixing the previous bug, meaning
   some other errors might exist but not being shown). As I said, no other cache
   plugin except the Cloudflare’s official one and I tried to deactivate it in vain.
   Would it be useful to delete the whole plugin through FTP (since I can’t activate
   it without getting an error making it impossible to use the site) and reinstall
   it ? Or would it be a waste of time anyway ?
 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18050105)
 * Yes, I think it would be interesting to remove the `wp-content\plugins\apcu-manager`
   folder AND the `wp-content\object-cache.php` file to see what going on.
   Then,
   if there’s no error, no “strange” things, reinstall APCu Manager…
    -  This reply was modified 1 year, 7 months ago by [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/).
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051218)
 * Hello again,
   I don’t have `wp-content\object-cache.php` Is that normal ?I tried
   to delete the apcu-manager folder and reinstall it but I get the same error.
 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051255)
 * This is not “normal” at all: this file is created by APCu Manager and without
   it, nothing can work…
 * This may reveal a wider problem affecting your entire site… Has APCu Manager 
   worked before on this site or has it never worked properly?
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051261)
 * Ok so I had a look at a backup and saw this object-cache.php. I copied it and
   put it again in wp-content, tried to activate the plugin but still got the issue.
   
   The thing is, when trying to delete the plugin and reinstall it, it didn’t re-
   create object-cache.php. That’s a problem, right ? It should have created a new
   one ?Edit: to answer, it was working right yes, but I think there was the object-
   cache.php file at the time and it has been deleted somehow
    -  This reply was modified 1 year, 7 months ago by [conradude](https://wordpress.org/support/users/hellodracon/).
 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051270)
 * Yes, it should. And you can’t just restore it from a backup as this file is actually“
   controlled” by WordPress itself.
 * Has APCu Manager worked before on this site or has it never worked properly?
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051281)
 * Yes it used to work great. I think I just deleted it by accident while fixing
   the other bug.
   What can I do to fix this then (since I can’t restore it from 
   a backup) ?thank you for you help, I feel dumb right now.
 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051320)
 * To be honest, I don’t think it’s *your* fault. The fact that activating the plugin
   cause the specified issue indicates that something else (may be: theme, plugin,
   mu-plugin or personal development) is “preempting” WordPress to correctly use
   cache. And it do it by forcing the load of the `WP_Object_Cache` class before
   it must be.
 * Have you noticed that this issue has occurred after you installed a new plugin,
   writen some lines of code, changed your theme, etc. ?
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051334)
 * I meant it’s my fault because I think I’ve probably deleted object-cache.php 
   by accident the day the plugin stopped working. That day, I discovered this error(
   that wasn’t here before since object-cache.php was there) but didn’t realize 
   I deleted the file at that time. 
   Nothing else happened (except this fix I told
   about before, but nothing connected).Do you have an idea what I should do ?Also,
   we had a problem with the plugin wpml and had links error in our different homepages(
   there were mixed up links between languages). And it looks like this wpml bug
   disappeared at the same time the apcu plugin stopped working. Could it be related?
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051455)
 * Ok, I moved the object-cache.php file that was in wp-content/mu-plugins to wp-
   content and activated the plugin and now it seems to be working.
    -  This reply was modified 1 year, 7 months ago by [conradude](https://wordpress.org/support/users/hellodracon/).
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051808)
 * Closing this thread as it’s fixed, I’ll open another for wpml. 
   Thanks again
 *  Plugin Author [Pierre Lannoy](https://wordpress.org/support/users/pierrelannoy/)
 * (@pierrelannoy)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051848)
 * > the object-cache.php file that was in wp-content/mu-plugins
 * Ok, it explains all symptoms. This is strictly “forbidden” to have something 
   that is not a mu-plugin inside this directory, because it is auto-loaded…
 * Very happy you find the root-cause. 🙂
 *  Thread Starter [conradude](https://wordpress.org/support/users/hellodracon/)
 * (@hellodracon)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051874)
 * Yes, I think i never deleted it but just moved it into mu-plugins.. So sorry 
   about everything.
   And thank you so much for your help and the plugins that are
   incredible really !

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Cannot declare class WP_Object_Cache,’ is closed to new replies.

 * ![](https://ps.w.org/apcu-manager/assets/icon-256x256.png?rev=2225345)
 * [APCu Manager](https://wordpress.org/plugins/apcu-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/apcu-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/apcu-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/apcu-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/apcu-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/apcu-manager/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [conradude](https://wordpress.org/support/users/hellodracon/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/cannot-declare-class-wp_object_cache/#post-18051874)
 * Status: resolved