From 0fdf37ec38a9f054bc40d17a3e66a0330e6029db Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 15:02:43 +0530 Subject: [PATCH 01/18] Move server-timing to top-level includes directory --- .../server-timing}/class-perflab-server-timing-metric.php | 0 .../server-timing}/class-perflab-server-timing.php | 0 {server-timing => includes/server-timing}/defaults.php | 0 {server-timing => includes/server-timing}/load.php | 0 {server-timing => includes/server-timing}/object-cache.copy.php | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {server-timing => includes/server-timing}/class-perflab-server-timing-metric.php (100%) rename {server-timing => includes/server-timing}/class-perflab-server-timing.php (100%) rename {server-timing => includes/server-timing}/defaults.php (100%) rename {server-timing => includes/server-timing}/load.php (100%) rename {server-timing => includes/server-timing}/object-cache.copy.php (100%) diff --git a/server-timing/class-perflab-server-timing-metric.php b/includes/server-timing/class-perflab-server-timing-metric.php similarity index 100% rename from server-timing/class-perflab-server-timing-metric.php rename to includes/server-timing/class-perflab-server-timing-metric.php diff --git a/server-timing/class-perflab-server-timing.php b/includes/server-timing/class-perflab-server-timing.php similarity index 100% rename from server-timing/class-perflab-server-timing.php rename to includes/server-timing/class-perflab-server-timing.php diff --git a/server-timing/defaults.php b/includes/server-timing/defaults.php similarity index 100% rename from server-timing/defaults.php rename to includes/server-timing/defaults.php diff --git a/server-timing/load.php b/includes/server-timing/load.php similarity index 100% rename from server-timing/load.php rename to includes/server-timing/load.php diff --git a/server-timing/object-cache.copy.php b/includes/server-timing/object-cache.copy.php similarity index 100% rename from server-timing/object-cache.copy.php rename to includes/server-timing/object-cache.copy.php From 6a3c9f9bd5685517e05de7a6addd70fa8e79da8e Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 15:14:59 +0530 Subject: [PATCH 02/18] Move site health tests from various focus areas to includes directory --- .../site-health}/audit-autoloaded-options/can-load.php | 0 .../site-health}/audit-autoloaded-options/helper.php | 0 .../site-health}/audit-autoloaded-options/hooks.php | 0 .../site-health}/audit-autoloaded-options/load.php | 0 .../site-health/audit-enqueued-assets}/can-load.php | 0 .../site-health}/audit-enqueued-assets/helper.php | 0 .../site-health}/audit-enqueued-assets/hooks.php | 0 .../site-health}/audit-enqueued-assets/load.php | 0 .../site-health/webp-support}/can-load.php | 0 {modules/images => includes/site-health}/webp-support/helper.php | 0 {modules/images => includes/site-health}/webp-support/hooks.php | 0 {modules/images => includes/site-health}/webp-support/load.php | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename {modules/database => includes/site-health}/audit-autoloaded-options/can-load.php (100%) rename {modules/database => includes/site-health}/audit-autoloaded-options/helper.php (100%) rename {modules/database => includes/site-health}/audit-autoloaded-options/hooks.php (100%) rename {modules/database => includes/site-health}/audit-autoloaded-options/load.php (100%) rename {modules/images/webp-support => includes/site-health/audit-enqueued-assets}/can-load.php (100%) rename {modules/js-and-css => includes/site-health}/audit-enqueued-assets/helper.php (100%) rename {modules/js-and-css => includes/site-health}/audit-enqueued-assets/hooks.php (100%) rename {modules/js-and-css => includes/site-health}/audit-enqueued-assets/load.php (100%) rename {modules/js-and-css/audit-enqueued-assets => includes/site-health/webp-support}/can-load.php (100%) rename {modules/images => includes/site-health}/webp-support/helper.php (100%) rename {modules/images => includes/site-health}/webp-support/hooks.php (100%) rename {modules/images => includes/site-health}/webp-support/load.php (100%) diff --git a/modules/database/audit-autoloaded-options/can-load.php b/includes/site-health/audit-autoloaded-options/can-load.php similarity index 100% rename from modules/database/audit-autoloaded-options/can-load.php rename to includes/site-health/audit-autoloaded-options/can-load.php diff --git a/modules/database/audit-autoloaded-options/helper.php b/includes/site-health/audit-autoloaded-options/helper.php similarity index 100% rename from modules/database/audit-autoloaded-options/helper.php rename to includes/site-health/audit-autoloaded-options/helper.php diff --git a/modules/database/audit-autoloaded-options/hooks.php b/includes/site-health/audit-autoloaded-options/hooks.php similarity index 100% rename from modules/database/audit-autoloaded-options/hooks.php rename to includes/site-health/audit-autoloaded-options/hooks.php diff --git a/modules/database/audit-autoloaded-options/load.php b/includes/site-health/audit-autoloaded-options/load.php similarity index 100% rename from modules/database/audit-autoloaded-options/load.php rename to includes/site-health/audit-autoloaded-options/load.php diff --git a/modules/images/webp-support/can-load.php b/includes/site-health/audit-enqueued-assets/can-load.php similarity index 100% rename from modules/images/webp-support/can-load.php rename to includes/site-health/audit-enqueued-assets/can-load.php diff --git a/modules/js-and-css/audit-enqueued-assets/helper.php b/includes/site-health/audit-enqueued-assets/helper.php similarity index 100% rename from modules/js-and-css/audit-enqueued-assets/helper.php rename to includes/site-health/audit-enqueued-assets/helper.php diff --git a/modules/js-and-css/audit-enqueued-assets/hooks.php b/includes/site-health/audit-enqueued-assets/hooks.php similarity index 100% rename from modules/js-and-css/audit-enqueued-assets/hooks.php rename to includes/site-health/audit-enqueued-assets/hooks.php diff --git a/modules/js-and-css/audit-enqueued-assets/load.php b/includes/site-health/audit-enqueued-assets/load.php similarity index 100% rename from modules/js-and-css/audit-enqueued-assets/load.php rename to includes/site-health/audit-enqueued-assets/load.php diff --git a/modules/js-and-css/audit-enqueued-assets/can-load.php b/includes/site-health/webp-support/can-load.php similarity index 100% rename from modules/js-and-css/audit-enqueued-assets/can-load.php rename to includes/site-health/webp-support/can-load.php diff --git a/modules/images/webp-support/helper.php b/includes/site-health/webp-support/helper.php similarity index 100% rename from modules/images/webp-support/helper.php rename to includes/site-health/webp-support/helper.php diff --git a/modules/images/webp-support/hooks.php b/includes/site-health/webp-support/hooks.php similarity index 100% rename from modules/images/webp-support/hooks.php rename to includes/site-health/webp-support/hooks.php diff --git a/modules/images/webp-support/load.php b/includes/site-health/webp-support/load.php similarity index 100% rename from modules/images/webp-support/load.php rename to includes/site-health/webp-support/load.php From 4e739afb8c13252312cb1cad51544e04d221294f Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 15:37:25 +0530 Subject: [PATCH 03/18] Add loader file for site health tests --- includes/site-health/load.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 includes/site-health/load.php diff --git a/includes/site-health/load.php b/includes/site-health/load.php new file mode 100644 index 0000000000..9b9381d2a6 --- /dev/null +++ b/includes/site-health/load.php @@ -0,0 +1,27 @@ + Date: Sat, 9 Mar 2024 15:42:00 +0530 Subject: [PATCH 04/18] Remove module based loading from site health tests --- .../audit-autoloaded-options/can-load.php | 19 ------------------- .../audit-autoloaded-options/load.php | 17 ----------------- .../audit-enqueued-assets/can-load.php | 19 ------------------- .../audit-enqueued-assets/load.php | 17 ----------------- .../site-health/webp-support/can-load.php | 19 ------------------- includes/site-health/webp-support/load.php | 17 ----------------- 6 files changed, 108 deletions(-) delete mode 100644 includes/site-health/audit-autoloaded-options/can-load.php delete mode 100644 includes/site-health/audit-autoloaded-options/load.php delete mode 100644 includes/site-health/audit-enqueued-assets/can-load.php delete mode 100644 includes/site-health/audit-enqueued-assets/load.php delete mode 100644 includes/site-health/webp-support/can-load.php delete mode 100644 includes/site-health/webp-support/load.php diff --git a/includes/site-health/audit-autoloaded-options/can-load.php b/includes/site-health/audit-autoloaded-options/can-load.php deleted file mode 100644 index 274a266348..0000000000 --- a/includes/site-health/audit-autoloaded-options/can-load.php +++ /dev/null @@ -1,19 +0,0 @@ - Date: Sat, 9 Mar 2024 15:52:14 +0530 Subject: [PATCH 05/18] Update phpstan.neon.dist --- phpstan.neon.dist | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 618e13ca19..55eff44c9d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,9 +7,8 @@ parameters: - default-enabled-modules.php - load.php - module-i18n.php - - modules/ + - includes/ - plugins/ - - server-timing/ - tests/ - uninstall.php scanDirectories: From 134cb632db0026201b13c4ea41d3f820a7ccafb2 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 16:16:10 +0530 Subject: [PATCH 06/18] Move server-timing and site health tests to tests/includes directory --- tests/{ => includes}/server-timing/load-tests.php | 0 .../server-timing/perflab-server-timing-metric-tests.php | 0 .../{ => includes}/server-timing/perflab-server-timing-tests.php | 0 .../audit-autoloaded-options/audit-autoloaded-options-test.php | 0 .../audit-enqueued-assets/audit-enqueued-assets-helper-test.php | 0 .../audit-enqueued-assets/audit-enqueued-assets-test.php | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => includes}/server-timing/load-tests.php (100%) rename tests/{ => includes}/server-timing/perflab-server-timing-metric-tests.php (100%) rename tests/{ => includes}/server-timing/perflab-server-timing-tests.php (100%) rename tests/{modules/database => includes/site-health}/audit-autoloaded-options/audit-autoloaded-options-test.php (100%) rename tests/{modules/js-and-css => includes/site-health}/audit-enqueued-assets/audit-enqueued-assets-helper-test.php (100%) rename tests/{modules/js-and-css => includes/site-health}/audit-enqueued-assets/audit-enqueued-assets-test.php (100%) diff --git a/tests/server-timing/load-tests.php b/tests/includes/server-timing/load-tests.php similarity index 100% rename from tests/server-timing/load-tests.php rename to tests/includes/server-timing/load-tests.php diff --git a/tests/server-timing/perflab-server-timing-metric-tests.php b/tests/includes/server-timing/perflab-server-timing-metric-tests.php similarity index 100% rename from tests/server-timing/perflab-server-timing-metric-tests.php rename to tests/includes/server-timing/perflab-server-timing-metric-tests.php diff --git a/tests/server-timing/perflab-server-timing-tests.php b/tests/includes/server-timing/perflab-server-timing-tests.php similarity index 100% rename from tests/server-timing/perflab-server-timing-tests.php rename to tests/includes/server-timing/perflab-server-timing-tests.php diff --git a/tests/modules/database/audit-autoloaded-options/audit-autoloaded-options-test.php b/tests/includes/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php similarity index 100% rename from tests/modules/database/audit-autoloaded-options/audit-autoloaded-options-test.php rename to tests/includes/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php diff --git a/tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-helper-test.php b/tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-helper-test.php similarity index 100% rename from tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-helper-test.php rename to tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-helper-test.php diff --git a/tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-test.php b/tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-test.php similarity index 100% rename from tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-test.php rename to tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-test.php From 71d4aebe10f7ce960aecac71125c0a953b62fcfe Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 16:21:56 +0530 Subject: [PATCH 07/18] Remove ref for legacy module slugs from perflab_get_module_settings() --- load.php | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/load.php b/load.php index f8c6069c28..a2c516e94a 100644 --- a/load.php +++ b/load.php @@ -30,10 +30,10 @@ define( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION', false ); } -require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/class-perflab-server-timing-metric.php'; -require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/class-perflab-server-timing.php'; -require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/load.php'; -require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/defaults.php'; +require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing-metric.php'; +require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing.php'; +require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/load.php'; +require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/defaults.php'; /** * Registers the performance modules setting. @@ -122,22 +122,7 @@ function perflab_get_module_settings() { // Even though a default value is registered for this setting, the default must be explicitly // passed here, to support scenarios where this function is called before the 'init' action, // for example when loading the active modules. - $module_settings = (array) get_option( PERFLAB_MODULES_SETTING, perflab_get_modules_setting_default() ); - - $legacy_module_slugs = array( - 'site-health/audit-autoloaded-options' => 'database/audit-autoloaded-options', - 'site-health/audit-enqueued-assets' => 'js-and-css/audit-enqueued-assets', - 'site-health/webp-support' => 'images/webp-support', - ); - - foreach ( $legacy_module_slugs as $legacy_slug => $current_slug ) { - if ( isset( $module_settings[ $legacy_slug ] ) ) { - $module_settings[ $current_slug ] = $module_settings[ $legacy_slug ]; - unset( $module_settings[ $legacy_slug ] ); - } - } - - return $module_settings; + return (array) get_option( PERFLAB_MODULES_SETTING, perflab_get_modules_setting_default() ); } /** From c303628482d5c73a2c97848ce67ee572eecba6c9 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 16:26:57 +0530 Subject: [PATCH 08/18] Fix webp support site health test name --- includes/site-health/load.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/site-health/load.php b/includes/site-health/load.php index 9b9381d2a6..8dd005cf03 100644 --- a/includes/site-health/load.php +++ b/includes/site-health/load.php @@ -18,7 +18,7 @@ $site_health_tests = array( 'audit-autoloaded-options', 'audit-enqueued-assets', - 'audit-webp-support' + 'webp-support' ); foreach ( $site_health_tests as $test ) { From 2fb4e7ad2d25da5731f25e0c607ed5c96b630ec6 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 18:01:41 +0530 Subject: [PATCH 09/18] Add site health tests to be loaded with plugin --- load.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/load.php b/load.php index a2c516e94a..957d63c3d7 100644 --- a/load.php +++ b/load.php @@ -30,11 +30,15 @@ define( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION', false ); } +// Load server-timing package. require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing-metric.php'; require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing.php'; require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/load.php'; require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/defaults.php'; +// Load site health tests. +require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/site-health/load.php'; + /** * Registers the performance modules setting. * From d7c36a5cbaad8480f541d9123cce482bdaccb8a1 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Sat, 9 Mar 2024 18:04:48 +0530 Subject: [PATCH 10/18] Update unit tests after removing site health tests from modules --- tests/load-tests.php | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/tests/load-tests.php b/tests/load-tests.php index 825fa09bd5..2d6608d1d1 100644 --- a/tests/load-tests.php +++ b/tests/load-tests.php @@ -97,36 +97,6 @@ static function ( $current_default, $option, $passed_default ) use ( &$has_passe $this->assertEqualSetsWithIndex( $new_value, $settings ); } - /** - * @dataProvider data_legacy_modules - */ - public function test_legacy_module_for_perflab_get_module_settings( $legacy_module_slug, $current_module_slug ) { - $new_value = array( $legacy_module_slug => array( 'enabled' => true ) ); - update_option( PERFLAB_MODULES_SETTING, $new_value ); - - $settings = perflab_get_module_settings(); - $this->assertArrayNotHasKey( $legacy_module_slug, $settings, 'The settings do not contain the old legacy module slug in the database' ); - $this->assertArrayHasKey( $current_module_slug, $settings, 'The settings contain an updated module slug in the database' ); - } - - /** - * Data provider for test_legacy_module_for_perflab_get_module_settings(). - * - * @return array { - * @type array { - * @type string $legacy_module_slug The legacy module slug. - * @type string $current_module_slug The new/updated module slug. - * } - * } - */ - public function data_legacy_modules() { - return array( - array( 'site-health/audit-autoloaded-options', 'database/audit-autoloaded-options' ), - array( 'site-health/audit-enqueued-assets', 'js-and-css/audit-enqueued-assets' ), - array( 'site-health/webp-support', 'images/webp-support' ), - ); - } - public function test_perflab_get_active_modules() { // Assert that by default there are no active modules. $active_modules = perflab_get_active_modules(); @@ -331,6 +301,6 @@ static function () { WP_Filesystem(); // Simulate that the original object-cache.copy.php file exists. - $wp_filesystem->put_contents( PERFLAB_PLUGIN_DIR_PATH . 'server-timing/object-cache.copy.php', file_get_contents( PERFLAB_PLUGIN_DIR_PATH . 'server-timing/object-cache.copy.php' ) ); + $wp_filesystem->put_contents( PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/object-cache.copy.php', file_get_contents( PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/object-cache.copy.php' ) ); } } From 8604b65b11aeacfa7d87865362a6c9ec8dee66ef Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 12 Mar 2024 01:51:36 +0530 Subject: [PATCH 11/18] Update site health checks loader --- includes/site-health/load.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/site-health/load.php b/includes/site-health/load.php index 8dd005cf03..f507416ccb 100644 --- a/includes/site-health/load.php +++ b/includes/site-health/load.php @@ -1,6 +1,6 @@ Date: Tue, 12 Mar 2024 01:53:37 +0530 Subject: [PATCH 12/18] Fix namings for PL core APIs --- load.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/load.php b/load.php index 957d63c3d7..fe9b35e7c9 100644 --- a/load.php +++ b/load.php @@ -30,13 +30,13 @@ define( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION', false ); } -// Load server-timing package. +// Load server-timing API. require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing-metric.php'; require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing.php'; require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/load.php'; require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/defaults.php'; -// Load site health tests. +// Load site health checks. require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/site-health/load.php'; /** From a06213df48c19a92a555366e3165fdfd55f85064 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 12 Mar 2024 02:03:53 +0530 Subject: [PATCH 13/18] Remove failing module test cases from tests --- tests/load-tests.php | 52 -------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/tests/load-tests.php b/tests/load-tests.php index 2d6608d1d1..b5393090ab 100644 --- a/tests/load-tests.php +++ b/tests/load-tests.php @@ -151,45 +151,6 @@ public function test_perflab_render_generator() { $this->assertStringContainsString( $expected, $output ); } - /** - * @dataProvider data_perflab_can_load_module - */ - public function test_perflab_is_valid_module( $dummy_module, $expected_status ) { - $this->assertSame( $expected_status, perflab_is_valid_module( $dummy_module ) ); - } - - public function data_perflab_is_valid_module() { - return array( - array( '', false ), - array( '../tests/testdata/demo-modules/something/non-existing-module', false ), - array( '../tests/testdata/demo-modules/js-and-css/demo-module-1', false ), - array( '../tests/testdata/demo-modules/something/demo-module-2', true ), - array( '../tests/testdata/demo-modules/images/demo-module-3', true ), - array( '../tests/testdata/demo-modules/check-error/demo-module-4', false ), - ); - } - - /** - * @dataProvider data_perflab_can_load_module - */ - public function test_perflab_can_load_module( $dummy_module, $expected_status ) { - $this->assertSame( $expected_status, perflab_can_load_module( $dummy_module ) ); - } - - public function data_perflab_can_load_module() { - return array( - array( '../tests/testdata/demo-modules/js-and-css/demo-module-1', false ), - array( '../tests/testdata/demo-modules/something/demo-module-2', true ), - array( '../tests/testdata/demo-modules/images/demo-module-3', true ), - ); - } - - public function test_perflab_can_load_module_with_not_loaded_module() { - $can_load_module = perflab_can_load_module( '../tests/testdata/demo-modules/check-error/demo-module-4' ); - $this->assertInstanceOf( 'WP_Error', $can_load_module ); - $this->assertSame( 'cannot_load_module', $can_load_module->get_error_code() ); - } - public function test_perflab_activate_module() { perflab_activate_module( __DIR__ . '/testdata/demo-modules/something/demo-module-2' ); $this->assertSame( 'activated', get_option( 'test_demo_module_activation_status' ) ); @@ -200,19 +161,6 @@ public function test_perflab_deactivate_module() { $this->assertSame( 'deactivated', get_option( 'test_demo_module_activation_status' ) ); } - private function get_expected_default_option() { - // This code is essentially copied over from the perflab_register_modules_setting() function. - $default_enabled_modules = require PERFLAB_PLUGIN_DIR_PATH . 'default-enabled-modules.php'; - return array_reduce( - $default_enabled_modules, - static function ( $module_settings, $module_dir ) { - $module_settings[ $module_dir ] = array( 'enabled' => true ); - return $module_settings; - }, - array() - ); - } - public function test_perflab_maybe_set_object_cache_dropin_no_conflict() { global $wp_filesystem; From 6d8d231158a40ac1afe6f85db3275d617ff19a37 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 12 Mar 2024 02:11:22 +0530 Subject: [PATCH 14/18] Fix server-timing API path --- load.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/load.php b/load.php index fe9b35e7c9..cf38b07c0c 100644 --- a/load.php +++ b/load.php @@ -413,7 +413,7 @@ function perflab_maybe_set_object_cache_dropin() { return; } - $wp_filesystem->copy( PERFLAB_PLUGIN_DIR_PATH . 'server-timing/object-cache.copy.php', $dropin_path ); + $wp_filesystem->copy( PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/object-cache.copy.php', $dropin_path ); } // Set timeout of 1 hour before retrying again (only relevant in case the above failed). From 29dfb4c2d040521af503010eb01c4ea7753599cd Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 12 Mar 2024 02:24:11 +0530 Subject: [PATCH 15/18] Update server-timing object-cache path and exclude pattern in phpcs.xml.dist --- includes/server-timing/object-cache.copy.php | 12 ++++++------ phpcs.xml.dist | 2 +- tests/load-tests.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/server-timing/object-cache.copy.php b/includes/server-timing/object-cache.copy.php index 7bd961b802..d0af56f6dd 100644 --- a/includes/server-timing/object-cache.copy.php +++ b/includes/server-timing/object-cache.copy.php @@ -58,17 +58,17 @@ function perflab_load_server_timing_api_from_dropin() { $plugins_dir = defined( 'WP_PLUGIN_DIR' ) ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins'; $plugin_dir = $plugins_dir . '/performance-lab/'; - if ( ! file_exists( $plugin_dir . 'server-timing/load.php' ) ) { + if ( ! file_exists( $plugin_dir . 'includes/server-timing/load.php' ) ) { $plugin_dir = $plugins_dir . '/performance/'; - if ( ! file_exists( $plugin_dir . 'server-timing/load.php' ) ) { + if ( ! file_exists( $plugin_dir . 'includes/server-timing/load.php' ) ) { return; } } - require_once $plugin_dir . 'server-timing/class-perflab-server-timing-metric.php'; - require_once $plugin_dir . 'server-timing/class-perflab-server-timing.php'; - require_once $plugin_dir . 'server-timing/load.php'; - require_once $plugin_dir . 'server-timing/defaults.php'; + require_once $plugin_dir . 'includes/server-timing/class-perflab-server-timing-metric.php'; + require_once $plugin_dir . 'includes/server-timing/class-perflab-server-timing.php'; + require_once $plugin_dir . 'includes/server-timing/load.php'; + require_once $plugin_dir . 'includes/server-timing/defaults.php'; } } perflab_load_server_timing_api_from_dropin(); diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 0c8967890a..042f680152 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -12,7 +12,7 @@ - server-timing/object-cache.copy.php + includes/server-timing/object-cache.copy.php . diff --git a/tests/load-tests.php b/tests/load-tests.php index b5393090ab..4eef28e58b 100644 --- a/tests/load-tests.php +++ b/tests/load-tests.php @@ -173,7 +173,7 @@ public function test_perflab_maybe_set_object_cache_dropin_no_conflict() { // Run function to place drop-in and ensure it exists afterwards. perflab_maybe_set_object_cache_dropin(); $this->assertTrue( $wp_filesystem->exists( WP_CONTENT_DIR . '/object-cache.php' ) ); - $this->assertSame( file_get_contents( PERFLAB_PLUGIN_DIR_PATH . 'server-timing/object-cache.copy.php' ), $wp_filesystem->get_contents( WP_CONTENT_DIR . '/object-cache.php' ) ); + $this->assertSame( file_get_contents( PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/object-cache.copy.php' ), $wp_filesystem->get_contents( WP_CONTENT_DIR . '/object-cache.php' ) ); } public function test_perflab_maybe_set_object_cache_dropin_no_conflict_but_failing() { From 7ef492a4af40cf10af18758da6d1bd6fc0c43015 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 12 Mar 2024 12:10:05 +0530 Subject: [PATCH 16/18] Bump object cache drop-in from 2 to 3 --- includes/server-timing/object-cache.copy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/server-timing/object-cache.copy.php b/includes/server-timing/object-cache.copy.php index d0af56f6dd..9add6a4809 100644 --- a/includes/server-timing/object-cache.copy.php +++ b/includes/server-timing/object-cache.copy.php @@ -34,7 +34,7 @@ // Set constant to be able to later check for whether this file was loaded. if ( ! defined( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION' ) ) { - define( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION', 2 ); + define( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION', 3 ); } if ( ! function_exists( 'perflab_load_server_timing_api_from_dropin' ) ) { From 686a8d99b5a2bdb82c0ea97710d0a054f2429b71 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Tue, 12 Mar 2024 13:35:25 +0530 Subject: [PATCH 17/18] Bump object cache drop-in plugin version from 2 to 3 --- includes/server-timing/object-cache.copy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/server-timing/object-cache.copy.php b/includes/server-timing/object-cache.copy.php index 9add6a4809..319483d375 100644 --- a/includes/server-timing/object-cache.copy.php +++ b/includes/server-timing/object-cache.copy.php @@ -3,7 +3,7 @@ * Plugin Name: Performance Lab Server Timing Object Cache Drop-In * Plugin URI: https://github.com/WordPress/performance * Description: Performance Lab drop-in to register Server-Timing metrics early. This is not a real object cache drop-in and will not override other actual object cache drop-ins. - * Version: 2 + * Version: 3 * Author: WordPress Performance Team * Author URI: https://make.wordpress.org/performance/ * License: GPLv2 or later From 86ff88bcd3fe3ff17a028fbd732cf7038ab074a7 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 13 Mar 2024 01:43:11 +0530 Subject: [PATCH 18/18] Remove site health caps safeguard --- includes/site-health/load.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/includes/site-health/load.php b/includes/site-health/load.php index f507416ccb..8cf164b302 100644 --- a/includes/site-health/load.php +++ b/includes/site-health/load.php @@ -10,10 +10,6 @@ exit; // Exit if accessed directly. } -if ( ! has_filter( 'user_has_cap', 'wp_maybe_grant_site_health_caps' ) ) { - return; -} - // Audit Autoloaded Options site health check. require_once __DIR__ . '/audit-autoloaded-options/helper.php'; require_once __DIR__ . '/audit-autoloaded-options/hooks.php';