From 9bc5cf1545778ec41aab39f844f8a7bac59c911d Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 26 Nov 2024 12:30:06 +0545 Subject: [PATCH] Make Requires Plugins header check stricter --- .../Checks/Plugin_Repo/Plugin_Header_Fields_Check.php | 4 ++-- .../test-plugin-unfiltered-uploads-with-errors/load.php | 2 +- .../Checker/Checks/Plugin_Header_Fields_Check_Tests.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php index 363ec5d60..2471b8c60 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php @@ -236,7 +236,7 @@ public function run( Check_Result $result ) { if ( ! empty( $plugin_header['RequiresPlugins'] ) ) { if ( ! preg_match( '/^[a-z0-9-]+(?:,\s*[a-z0-9-]+)*$/', $plugin_header['RequiresPlugins'] ) ) { - $this->add_result_warning_for_file( + $this->add_result_error_for_file( $result, sprintf( /* translators: %s: plugin header field */ @@ -248,7 +248,7 @@ public function run( Check_Result $result ) { 0, 0, '', - 6 + 7 ); } } diff --git a/tests/phpunit/testdata/plugins/test-plugin-unfiltered-uploads-with-errors/load.php b/tests/phpunit/testdata/plugins/test-plugin-unfiltered-uploads-with-errors/load.php index 8e0d259cf..1c9c87e57 100644 --- a/tests/phpunit/testdata/plugins/test-plugin-unfiltered-uploads-with-errors/load.php +++ b/tests/phpunit/testdata/plugins/test-plugin-unfiltered-uploads-with-errors/load.php @@ -4,7 +4,7 @@ * Plugin URI: https://github.com/WordPress/plugin-check * Description: Test plugin for the Localhost check. * Requires at least: 6.0 - * Requires PHP: 5.6 + * Requires PHP: latest * Version: 1.0.0 * Author: WordPress Performance Team * Author URI: https://make.wordpress.org/performance/ diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php index 54ef73e85..d551c6c83 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php @@ -36,7 +36,7 @@ public function test_run_with_errors() { $this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_network' ) ) ); if ( is_wp_version_compatible( '6.5' ) ) { - $this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) ); + $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) ); } } @@ -52,10 +52,10 @@ public function test_run_with_valid_requires_plugins_header() { $check->run( $check_result ); - $warnings = $check_result->get_warnings(); + $errors = $check_result->get_errors(); if ( is_wp_version_compatible( '6.5' ) ) { - $this->assertCount( 0, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) ); + $this->assertCount( 0, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) ); } }