diff --git a/CHANGELOG.md b/CHANGELOG.md index 922a5183..01b65cd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,12 @@ ## Unreleased - Require WordPress 4.6 or newer -- Load text-domain on-demand -- Call `redis_object_cache_error` action before `wp_die()` -- Don't try to define `WP_REDIS_PLUGIN_PATH` twice +- Load text-domain only when needed +- Added `WP_REDIS_DISABLE_DROPIN_CHECK` constant - Respect `file_mod_allowed` filter and `DISALLOW_FILE_MODS` constant - Renamed `.redis-write-test.tmp` test file to `object-cache.tmp` +- Call `redis_object_cache_error` action before `wp_die()` +- Allow `WP_REDIS_PLUGIN_PATH` to be defined elsewhere ## 2.4.4 diff --git a/README.md b/README.md index 25d34383..20594f70 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ The Redis Object Cache plugin comes with vast set of configuration options. If y | `WP_REDIS_DISABLE_ADMINBAR` | `false` | Disables admin bar display | | `WP_REDIS_DISABLE_METRICS` | `false` | Disables metrics collection and display | | `WP_REDIS_DISABLE_BANNERS` | `false` | Disables promotional banners | +| `WP_REDIS_DISABLE_DROPIN_CHECK` | `false` | Disables the extended drop-in write test | | `WP_REDIS_DISABLE_DROPIN_AUTOUPDATE` | `false` | Disables the drop-in auto-update | | `WP_REDIS_SSL_CONTEXT` | `[]` | TLS connection options for `tls` or `rediss` scheme | diff --git a/includes/class-plugin.php b/includes/class-plugin.php index 05a3cba5..047d980c 100644 --- a/includes/class-plugin.php +++ b/includes/class-plugin.php @@ -1391,6 +1391,20 @@ public function test_filesystem_writing() { return new WP_Error( 'fs', __( 'Could not initialize filesystem.', 'redis-cache' ) ); } + $dropin_check = ! defined( 'WP_REDIS_DISABLE_DROPIN_CHECK' ) || ! WP_REDIS_DISABLE_DROPIN_CHECK; + + if ( ! $dropin_check ) { + if ( ! $wp_filesystem->exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { + return true; + } + + if ( ! $wp_filesystem->is_writable( WP_CONTENT_DIR . '/object-cache.php' ) ) { + return new WP_Error( 'writable', __( 'Object cache drop-in is not writable.', 'redis-cache' ) ); + } + + return true; + } + $cachefile = WP_REDIS_PLUGIN_PATH . '/includes/object-cache.php'; $testfile = WP_CONTENT_DIR . '/object-cache.tmp'; @@ -1405,7 +1419,7 @@ public function test_filesystem_writing() { } if ( ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) { - return new WP_Error( 'copy', __( 'Content directory is not writable.', 'redis-cache' ) ); + return new WP_Error( 'writable', __( 'Content directory is not writable.', 'redis-cache' ) ); } if ( ! $wp_filesystem->copy( $cachefile, $testfile, true, FS_CHMOD_FILE ) ) {