keycdn / cache-enabler

A lightweight caching plugin for WordPress that makes your website faster by generating static HTML files.
https://wordpress.org/plugins/cache-enabler/
123 stars 46 forks source link

PHP Warning for CACHE_ENABLER_DIR constant #232

Closed UVLabs closed 3 years ago

UVLabs commented 3 years ago

Issue is on this line: https://github.com/keycdn/cache-enabler/blob/master/inc/cache_enabler_disk.class.php#L60

Use of undefined constant CACHE_ENABLER_DIR - assumed 'CACHE_ENABLER_DIR' (this will throw an Error in a future version of PHP) in /Users/uvdev/Local Sites/skraveshippingdev/app/public/wp-content/plugins/cache-enabler/inc/cache_enabler_disk.class.php on line 60

This is also causing the plugin to not find and copy the advanced-cache file to wp-content folder:

image

image

Tested on PHP 7.3 and 7.4.1

coreykn commented 3 years ago

I'm unable to replicate this issue when updating the plugin from an old version to 1.7+. The CACHE_ENABLER_DIR constant is currently defined in the cache-enabler.php file: https://github.com/keycdn/cache-enabler/blob/1.7.1/cache-enabler.php

To troubleshoot this further, please answer the following questions at your convenience:

  1. What version did you update from?
  2. How was your plugin updated when this occurred?
  3. What type of WordPress website do you have? For example, a single or multisite installation.
  4. Do you have steps that can be taken to replicate it?
UVLabs commented 3 years ago
coreykn commented 3 years ago

Thanks for the additional information, @UVLabs. I just ran a few tests updating from v1.3.5 to v1.7.1 in the way you described as well as another and was unable to replicate this issue. This was done both locally and remotely.

As you may already know, upgrader_process_complete, the hook Cache_Enabler::on_ce_update() is registered to (now Cache_Enabler::on_cache_enabler_update()), does have a caveat as the way we're using it makes it run the old version of the plugin. However, that's the entire old version of the plugin and not just a part of it. For example, that is why Cache_Enabler::on_ce_update() was called instead of Cache_Enabler::on_cache_enabler_update(). I believe it has been since PR #166 we've fully taken this into account to ensure our updates do what we need.

Unfortunately I'm unsure why this occurred to you and am unable to test with the local solution that you're using. You are the first that I'm aware of that has experienced this issue. In this case I would recommend reinstalling the plugin.

coreykn commented 3 years ago

I'm going to close this as I think what occurred to you was just an odd case. However, if you need me to do any further investigating please feel free to open it again.

UVLabs commented 3 years ago

@coreykn Ok, I'm going to be updating it on the live site soon, if the issue still occurs then ill just delete the plugin and install from the repo again