• 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)
  • Hi @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.

    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

    (@rsm-support)

    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.