Skip to content

Commit

Permalink
added WP_REDIS_DISABLE_DROPIN_CHECK
Browse files Browse the repository at this point in the history
run shorter, less hostile FS check when `true`
  • Loading branch information
tillkruss committed Nov 5, 2023
1 parent df87cc2 commit d658193
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
16 changes: 15 additions & 1 deletion includes/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 ) ) {
Expand Down

0 comments on commit d658193

Please sign in to comment.