Title: PHP Error: Constant already defined &#8211; DONOTDELETECACHE
Last modified: September 12, 2017

---

# PHP Error: Constant already defined – DONOTDELETECACHE

 *  [rsm-support](https://wordpress.org/support/users/rsm-support/)
 * (@rsm-support)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/php-error-constant-already-defined-donotdeletecache/)
 * We run WP_DEBUG in logging mode. PHP 7.0.
 * This PHP error (NOTICE level, but still an error) shows up regularly in the logs:
 *     ```
       PHP Notice:  Constant DONOTDELETECACHE already defined in {DOCUMENT_ROOT}/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 1289
       ```
   
 * Please replace all occurrences of the `define()` directive to make them conditional—
   only define if not already defined.
 * Like so…the fix for line 1289 is to change it from
 *     ```
       define( 'DONOTDELETECACHE', 1 );
       ```
   
 * to
 *     ```
       if( !defined( 'DONOTDELETECACHE' ) ) { define( 'DONOTDELETECACHE', 1 ); }
       ```
   
 * Thank you.

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

 *  [Saša](https://wordpress.org/support/users/stodorovic/)
 * (@stodorovic)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/php-error-constant-already-defined-donotdeletecache/#post-9493726)
 * Hi [@rsm-support](https://wordpress.org/support/users/rsm-support/)
 * Thanks for reporting this issue. I’m not sure that this code is good solution
   because there are more occurrences of `define( 'DONOTDELETECACHE', 1 )`. I was
   able to get stack trace for these notices and I created [https://github.com/Automattic/wp-super-cache/issues/385](https://github.com/Automattic/wp-super-cache/issues/385).
 * Do you have more info how to trigger code which reports them? I’m guessing that’s
   related to wp-cron.php and xmlrpc.php.
 * Regards,
    Sasa
 *  Thread Starter [rsm-support](https://wordpress.org/support/users/rsm-support/)
 * (@rsm-support)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/php-error-constant-already-defined-donotdeletecache/#post-9493772)
 * Hi Sasa,
 * No problem.
 * > I’m not sure that this code is good solution because there are more occurrences
   > of define( ‘DONOTDELETECACHE’, 1 ).
 * That’s why I said:
 * > Please replace all occurrences of the define() directive to make them conditional—
   > only define if not already defined.
 * 🙂
 * If I remember correctly there were only 5 instances of it, all in the same file.
   I’d have to double-check, so don’t quote me on that. A quick grep of the plugin
   files will turn all of them up.
 * I didn’t debug the whole plugin. These occurred randomly. The logic would need
   to be examined and backtraces run. I’d suggest using WP_DEBUG in logging mode
   along with Query Monitor.

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

The topic ‘PHP Error: Constant already defined – DONOTDELETECACHE’ is closed to 
new replies.

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

 * 2 replies
 * 2 participants
 * Last reply from: [rsm-support](https://wordpress.org/support/users/rsm-support/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/php-error-constant-already-defined-donotdeletecache/#post-9493772)
 * Status: not resolved