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 {
145145 * the frontend.
146146 *
147147 * 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.
150151 *
151152 * @since 1.8.0
152153 * @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.
153155 *
154156 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
155157 */
@@ -161,7 +163,14 @@ function perflab_maybe_set_object_cache_dropin(): void {
161163 return ;
162164 }
163165
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+
164171 // 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.
165174 if ( defined ( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ' ) && PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ) {
166175 return ;
167176 }
Original file line number Diff line number Diff line change 77
88class Test_Load extends WP_UnitTestCase {
99
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+
1025 public function test_perflab_get_generator_content (): void {
1126 $ expected = 'performance-lab ' . PERFLAB_VERSION . '; plugins: ' ;
1227 $ content = perflab_get_generator_content ();
You can’t perform that action at this time.
0 commit comments