run:R W Run
DIR
2026-04-09 18:51:36
R W Run
DIR
2026-04-09 18:51:36
R W Run
DIR
2026-04-09 18:51:36
R W Run
DIR
2026-04-09 18:51:36
R W Run
DIR
2026-04-09 18:51:36
R W Run
12.01 KB
2026-04-09 18:51:36
R W Run
2.73 KB
2026-04-09 18:51:36
R W Run
6.68 KB
2026-04-09 18:51:36
R W Run
6.81 KB
2026-04-09 18:51:36
R W Run
45.08 KB
2026-04-09 18:51:36
R W Run
17.64 KB
2026-04-09 18:51:36
R W Run
9.33 KB
2026-04-09 18:51:36
R W Run
6.15 KB
2026-04-09 18:51:36
R W Run
3.05 KB
2026-04-09 18:51:36
R W Run
6.14 KB
2026-04-09 18:51:36
R W Run
13.79 KB
2026-04-09 18:51:36
R W Run
2.87 KB
2026-04-09 18:51:36
R W Run
6.06 KB
2026-04-09 18:51:36
R W Run
12.6 KB
2026-04-09 18:51:36
R W Run
error_log
📄Dropin.php
1<?php
2/**
3 * Copyright © 2019-2026 Rhubarb Tech Inc. All Rights Reserved.
4 *
5 * The Object Cache Pro Software and its related materials are property and confidential
6 * information of Rhubarb Tech Inc. Any reproduction, use, distribution, or exploitation
7 * of the Object Cache Pro Software and its related materials, in whole or in part,
8 * is strictly forbidden unless prior permission is obtained from Rhubarb Tech Inc.
9 *
10 * In addition, any reproduction, use, distribution, or exploitation of the Object Cache Pro
11 * Software and its related materials, in whole or in part, is subject to the End-User License
12 * Agreement accessible in the included `LICENSE` file, or at: https://objectcache.pro/eula
13 */
14
15declare(strict_types=1);
16
17namespace RedisCachePro\Plugin;
18
19use Throwable;
20
21/**
22 * @mixin \RedisCachePro\Plugin
23 */
24trait Dropin
25{
26 /**
27 * Boot dropin component.
28 *
29 * @return void
30 */
31 public function bootDropin()
32 {
33 add_action('file_mod_allowed', [$this, 'applyFileModFilters'], 10, 2);
34 add_action('upgrader_process_complete', [$this, 'maybeUpdateDropin'], 10, 2);
35
36 // prevent server-timing drop-in hijack
37 add_filter('perflab_disable_object_cache_dropin', '__return_true');
38 }
39
40 /**
41 * Returns true if the object cache is disabled via constant or environment variable.
42 *
43 * @return bool
44 */
45 public function isDisabled()
46 {
47 if (! empty(getenv('WP_REDIS_DISABLED'))) {
48 return true;
49 }
50
51 return defined('WP_REDIS_DISABLED') && \WP_REDIS_DISABLED;
52 }
53
54 /**
55 * Adds shortcut filters to core's `file_mod_allowed` filter.
56 *
57 * @param bool $file_mod_allowed
58 * @param string $context
59 * @return bool
60 */
61 public function applyFileModFilters($file_mod_allowed, $context)
62 {
63 if ($context === 'object_cache_dropin') {
64 /**
65 * Filters whether drop-in file modifications are allowed.
66 *
67 * @param bool $dropin_mod_allowed Whether drop-in modifications are allowed.
68 */
69 return (bool) apply_filters('objectcache_allow_dropin_mod', $file_mod_allowed);
70 }
71
72 return $file_mod_allowed;
73 }
74
75 /**
76 * Attempt to enable the object cache drop-in.
77 *
78 * @return bool
79 */
80 public function enableDropin()
81 {
82 global $wp_filesystem;
83
84 if (! \WP_Filesystem()) {
85 return false;
86 }
87
88 $dropin = \WP_CONTENT_DIR . '/object-cache.php';
89 $stub = "{$this->directory}/stubs/object-cache.php";
90
91 $result = $wp_filesystem->copy($stub, $dropin, true, FS_CHMOD_FILE);
92
93 if (function_exists('wp_opcache_invalidate')) {
94 wp_opcache_invalidate($dropin, true);
95 }
96
97 /**
98 * Filters whether to automatically flush the object after enabling the drop-in.
99 *
100 * @param bool $autoflush Whether to auto-flush the object cache. Default true.
101 */
102 if ((bool) apply_filters('objectcache_autoflush', true)) {
103 $this->resetCache();
104 }
105
106 /**
107 * Filters whether to delete transients from the database after enabling the drop-in.
108 *
109 * @param bool $delete Whether to delete the transients. Default true.
110 */
111 if ((bool) apply_filters('objectcache_cleanup_transients', true)) {
112 add_action('shutdown', [$this, 'deleteTransients']);
113 }
114
115 return $result;
116 }
117
118 /**
119 * Attempt to disable the object cache drop-in.
120 *
121 * @return bool
122 */
123 public function disableDropin()
124 {
125 global $wp_filesystem;
126
127 if (! wp_is_file_mod_allowed('object_cache_dropin')) {
128 return false;
129 }
130
131 if (! \WP_Filesystem()) {
132 return false;
133 }
134
135 $dropin = \WP_CONTENT_DIR . '/object-cache.php';
136
137 if (! $wp_filesystem->exists($dropin)) {
138 return false;
139 }
140
141 $result = $wp_filesystem->delete($dropin);
142
143 if (function_exists('wp_opcache_invalidate')) {
144 wp_opcache_invalidate($dropin, true);
145 }
146
147 /**
148 * Filters whether to automatically flush the object after disabling the drop-in.
149 *
150 * @param bool $autoflush Whether to auto-flush the object cache. Default true.
151 */
152 if ((bool) apply_filters('objectcache_autoflush', true)) {
153 $this->resetCache(false);
154 }
155
156 return $result;
157 }
158
159 /**
160 * Attempt to update the object cache drop-in.
161 *
162 * @return bool
163 */
164 public function updateDropin()
165 {
166 global $wp_filesystem;
167
168 if (! \WP_Filesystem()) {
169 return false;
170 }
171
172 $dropin = \WP_CONTENT_DIR . '/object-cache.php';
173 $stub = "{$this->directory}/stubs/object-cache.php";
174
175 $result = $wp_filesystem->copy($stub, $dropin, true, FS_CHMOD_FILE);
176
177 if (function_exists('wp_opcache_invalidate')) {
178 wp_opcache_invalidate($dropin, true);
179 }
180
181 return $result;
182 }
183
184 /**
185 * Update the object cache drop-in, if it's outdated.
186 *
187 * @param \WP_Upgrader $upgrader
188 * @param array<string, mixed> $options
189 * @return bool|void
190 */
191 public function maybeUpdateDropin($upgrader, $options)
192 {
193 $this->verifyDropin();
194
195 if (! wp_is_file_mod_allowed('object_cache_dropin')) {
196 return;
197 }
198
199 if ($options['action'] !== 'update' || $options['type'] !== 'plugin') {
200 return;
201 }
202
203 if (! in_array($this->basename, $options['plugins'] ?? [])) {
204 return;
205 }
206
207 $diagnostics = $this->diagnostics();
208
209 if (! $diagnostics->dropinExists() || ! $diagnostics->dropinIsValid()) {
210 return;
211 }
212
213 if ($diagnostics->dropinIsUpToDate()) {
214 return;
215 }
216
217 return $this->updateDropin();
218 }
219
220 /**
221 * Verifies the object cache drop-in.
222 *
223 * @return void
224 */
225 public function verifyDropin()
226 {
227 if (! $this->license()->isValid()) {
228 $this->disableDropin();
229 }
230 }
231
232 /**
233 * Initializes and connects the WordPress Filesystem Abstraction classes.
234 *
235 * @return \WP_Filesystem_Base
236 */
237 protected function wpFilesystem()
238 {
239 global $wp_filesystem;
240
241 try {
242 require_once \ABSPATH . 'wp-admin/includes/plugin.php';
243 } catch (Throwable $th) {
244 //
245 }
246
247 if (! \WP_Filesystem()) {
248 try {
249 require_once \ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
250 require_once \ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
251 } catch (Throwable $th) {
252 //
253 }
254
255 return new \WP_Filesystem_Direct(null);
256 }
257
258 return $wp_filesystem;
259 }
260}
261