Title: Cannot redeclare wp_cache_add while using wp-cli
Last modified: February 27, 2019

---

# Cannot redeclare wp_cache_add while using wp-cli

 *  Resolved [Vineet Talwar](https://wordpress.org/support/users/vineettalwar/)
 * (@vineettalwar)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/)
 * Following is the error message,
    `PHP Fatal error: Cannot redeclare wp_cache_add()(
   previously declared in /htdocs/wp-content/object-cache.php:92) in /htdocs/wp-
   includes/cache.php on line 31`
 * While running, any wp cli command throws aforementioned error message.
    – WordPress:
   5.1 multisite installation – /wp-content/object-cache.php is present and running
   updated code from from /wp-content/plugins/w3-total-cache/wp-content/object-cache.
   php
 * — issue started, after I have upgraded to WordPress 5.1 to my installations.
   —
   Now no wp-cli command is working.

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

 *  Thread Starter [Vineet Talwar](https://wordpress.org/support/users/vineettalwar/)
 * (@vineettalwar)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/#post-11255210)
 * Also, deactivation and reactivation of plugin, haven’t worked for me, as it worked
   for this ticket.
    [https://wordpress.org/support/topic/w3tc-wp-cli-problem/](https://wordpress.org/support/topic/w3tc-wp-cli-problem/)
 *  [Benjamin Danon](https://wordpress.org/support/users/bndn/)
 * (@bndn)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/#post-11268678)
 * I have the same problem here. Upgrade to WP 5.1, WP-CLI, nothing happens after
   deactivating/activating W3TC.
 *  [Benjamin Danon](https://wordpress.org/support/users/bndn/)
 * (@bndn)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/#post-11271755)
 * I tried to dig into this bug. It is related with [this changes commited one year ago](https://github.com/WordPress/WordPress/commit/edfe2ece51edc40e2bca866b95eb7587966a5851)
   in WP trunk that just land in WP 5.1 and more precisely with the usage of the
   static variable named `$first_init`. The object cache is disabled (`ObjectCache_WpObjectCache_Regular.
   php, line 792`) because cli mode is detected, but now the `wp_using_ext_object_cache()`
   is not checked anymore on line 566, then `cache.php` is loaded.
    I’m not able
   to say if there is an error with loading cache in WP trunk or if W3TC should 
   disable the object cache in an other way.
 *  [copytrans](https://wordpress.org/support/users/copytrans/)
 * (@copytrans)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/#post-11275199)
 * Exact same problem here.
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/#post-11277048)
 * Hello,
 * Please check the following topic as the solution is provided there => [https://wordpress.org/support/topic/cannot-redeclare-wp_cache_xxx/#post-11277041](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_xxx/#post-11277041)
 *  Thread Starter [Vineet Talwar](https://wordpress.org/support/users/vineettalwar/)
 * (@vineettalwar)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/#post-11317427)
 * Thank you for the solution.
    The issue is fixed as of now with mentioned solution.
   Will Look forward for next update.

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

The topic ‘Cannot redeclare wp_cache_add while using wp-cli’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [Vineet Talwar](https://wordpress.org/support/users/vineettalwar/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/cannot-redeclare-wp_cache_add-while-using-wp-cli/#post-11317427)
 * Status: resolved