File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -145,11 +145,13 @@ function perflab_get_standalone_plugin_version_constants(): array {
145
145
* the frontend.
146
146
*
147
147
* This function will short-circuit if at least one of the constants
148
- * 'PERFLAB_DISABLE_SERVER_TIMING' or 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' is
149
- * set as true.
148
+ * 'PERFLAB_DISABLE_SERVER_TIMING' or
149
+ * 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' is set as true or if the
150
+ * 'PERFLAB_PLACE_OBJECT_CACHE_DROPIN' constant is not set to a truthy value.
150
151
*
151
152
* @since 1.8.0
152
153
* @since 2.1.0 No longer attempts to use two of the drop-ins together.
154
+ * @since n.e.x.t No longer places the drop-in on new sites by default, unless the `PERFLAB_PLACE_OBJECT_CACHE_DROPIN` constant is set to true.
153
155
*
154
156
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
155
157
*/
@@ -161,7 +163,14 @@ function perflab_maybe_set_object_cache_dropin(): void {
161
163
return ;
162
164
}
163
165
166
+ // Bail if the drop-in is not enabled.
167
+ if ( ! defined ( 'PERFLAB_PLACE_OBJECT_CACHE_DROPIN ' ) || ! PERFLAB_PLACE_OBJECT_CACHE_DROPIN ) {
168
+ return ;
169
+ }
170
+
164
171
// Bail if disabled via constant.
172
+ // This constant is maintained only for backward compatibility and should not be relied upon in new implementations.
173
+ // Use the 'PERFLAB_PLACE_OBJECT_CACHE_DROPIN' constant instead to control drop-in placement.
165
174
if ( defined ( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ' ) && PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ) {
166
175
return ;
167
176
}
Original file line number Diff line number Diff line change 7
7
8
8
class Test_Load extends WP_UnitTestCase {
9
9
10
+ /**
11
+ * Runs the routine before each test is executed.
12
+ */
13
+ public function set_up (): void {
14
+ parent ::set_up ();
15
+
16
+ /*
17
+ * This constant is not set by default in production.
18
+ * However, it is needed for all tests that cover placement of the object cache drop-in.
19
+ */
20
+ if ( ! defined ( 'PERFLAB_PLACE_OBJECT_CACHE_DROPIN ' ) ) {
21
+ define ( 'PERFLAB_PLACE_OBJECT_CACHE_DROPIN ' , true );
22
+ }
23
+ }
24
+
10
25
public function test_perflab_get_generator_content (): void {
11
26
$ expected = 'performance-lab ' . PERFLAB_VERSION . '; plugins: ' ;
12
27
$ content = perflab_get_generator_content ();
You can’t perform that action at this time.
0 commit comments