Skip to content

Commit d658193

Browse files
committed
added WP_REDIS_DISABLE_DROPIN_CHECK
run shorter, less hostile FS check when `true`
1 parent df87cc2 commit d658193

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
## Unreleased
44

55
- Require WordPress 4.6 or newer
6-
- Load text-domain on-demand
7-
- Call `redis_object_cache_error` action before `wp_die()`
8-
- Don't try to define `WP_REDIS_PLUGIN_PATH` twice
6+
- Load text-domain only when needed
7+
- Added `WP_REDIS_DISABLE_DROPIN_CHECK` constant
98
- Respect `file_mod_allowed` filter and `DISALLOW_FILE_MODS` constant
109
- Renamed `.redis-write-test.tmp` test file to `object-cache.tmp`
10+
- Call `redis_object_cache_error` action before `wp_die()`
11+
- Allow `WP_REDIS_PLUGIN_PATH` to be defined elsewhere
1112

1213
## 2.4.4
1314

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The Redis Object Cache plugin comes with vast set of configuration options. If y
5858
| `WP_REDIS_DISABLE_ADMINBAR` | `false` | Disables admin bar display |
5959
| `WP_REDIS_DISABLE_METRICS` | `false` | Disables metrics collection and display |
6060
| `WP_REDIS_DISABLE_BANNERS` | `false` | Disables promotional banners |
61+
| `WP_REDIS_DISABLE_DROPIN_CHECK` | `false` | Disables the extended drop-in write test |
6162
| `WP_REDIS_DISABLE_DROPIN_AUTOUPDATE` | `false` | Disables the drop-in auto-update |
6263
| `WP_REDIS_SSL_CONTEXT` | `[]` | TLS connection options for `tls` or `rediss` scheme |
6364

includes/class-plugin.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,20 @@ public function test_filesystem_writing() {
13911391
return new WP_Error( 'fs', __( 'Could not initialize filesystem.', 'redis-cache' ) );
13921392
}
13931393

1394+
$dropin_check = ! defined( 'WP_REDIS_DISABLE_DROPIN_CHECK' ) || ! WP_REDIS_DISABLE_DROPIN_CHECK;
1395+
1396+
if ( ! $dropin_check ) {
1397+
if ( ! $wp_filesystem->exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
1398+
return true;
1399+
}
1400+
1401+
if ( ! $wp_filesystem->is_writable( WP_CONTENT_DIR . '/object-cache.php' ) ) {
1402+
return new WP_Error( 'writable', __( 'Object cache drop-in is not writable.', 'redis-cache' ) );
1403+
}
1404+
1405+
return true;
1406+
}
1407+
13941408
$cachefile = WP_REDIS_PLUGIN_PATH . '/includes/object-cache.php';
13951409
$testfile = WP_CONTENT_DIR . '/object-cache.tmp';
13961410

@@ -1405,7 +1419,7 @@ public function test_filesystem_writing() {
14051419
}
14061420

14071421
if ( ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) {
1408-
return new WP_Error( 'copy', __( 'Content directory is not writable.', 'redis-cache' ) );
1422+
return new WP_Error( 'writable', __( 'Content directory is not writable.', 'redis-cache' ) );
14091423
}
14101424

14111425
if ( ! $wp_filesystem->copy( $cachefile, $testfile, true, FS_CHMOD_FILE ) ) {

0 commit comments

Comments
 (0)