• Hey there,

    Thanks for the great plugin, by far my favorite caching plugin.

    I’ve however, discovered a bug. When defining the constant “DONOTCACHEPAGE” and setting it to false, i.e. we should cache the page, W3TC ignores the value of the constant and assumes you don’t want to cache the page because that constant is defined.

    The error is in PgCache.php in the process method on line 164:

    switch (true) {
                case defined('DONOTCACHEPAGE'):
                case defined('DOING_AJAX'):
                case defined('DOING_CRON'):
                case defined('APP_REQUEST'):
                case defined('XMLRPC_REQUEST'):
                case defined('WP_ADMIN'):
                case (defined('SHORTINIT') && SHORTINIT):
                    return;
            }

    That should not just check that it is defined but also check if it is true/false.

    It’s done correctly on line 515:

    if (defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) {
                $this->cache_reject_reason = 'DONOTCACHEPAGE constant is defined';
    
                return false;
            }

    but because of the code in process.php, it never caches any pages if the constant is set to false.

    Was hoping there was a Github repo so that I could do a fix and send a pull request, but I suppose this forum is the next best thing ??

    Thanks,
    Matt

    https://www.ads-software.com/plugins/w3-total-cache/

  • The topic ‘Bug when using DONOTCACHEPAGE’ is closed to new replies.