From 4f023111311f54849c819c39d1340ead1aee8cd2 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 23 Sep 2022 14:38:37 +0530 Subject: [PATCH 01/41] Run PHP unit tests in different versions of PHP --- .github/workflows/php-test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 53fe0a1780..28363e4af4 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -33,9 +33,15 @@ on: jobs: php-test: - name: PHP + name: "PHP ${{ matrix.php }}" runs-on: ubuntu-latest timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + php: ['5.6', '7.4', '8.1'] + env: + WP_ENV_PHP_VERSION: ${{ matrix.php }}-fpm steps: - uses: styfle/cancel-workflow-action@0.8.0 - uses: actions/checkout@v3 From c3898bdd45dfe9102f7ce6b27f34c8d1e559017f Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 23 Sep 2022 14:49:34 +0530 Subject: [PATCH 02/41] Use LOCAL_PHP --- .github/workflows/php-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 28363e4af4..b3811c4df4 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -41,7 +41,7 @@ jobs: matrix: php: ['5.6', '7.4', '8.1'] env: - WP_ENV_PHP_VERSION: ${{ matrix.php }}-fpm + LOCAL_PHP: ${{ matrix.php }}-fpm steps: - uses: styfle/cancel-workflow-action@0.8.0 - uses: actions/checkout@v3 From ebbc526fabe94c1dd0ff1674c2cdb7fb1d4083db Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 23 Sep 2022 15:13:10 +0530 Subject: [PATCH 03/41] Update ENV --- .github/workflows/php-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index b3811c4df4..29f4b164b6 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -41,7 +41,7 @@ jobs: matrix: php: ['5.6', '7.4', '8.1'] env: - LOCAL_PHP: ${{ matrix.php }}-fpm + WP_ENV_PHP_VERSION: ${{ matrix.php }} steps: - uses: styfle/cancel-workflow-action@0.8.0 - uses: actions/checkout@v3 From 734f83a450d027c4761a4976577ef459a09aae39 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 9 Dec 2022 14:54:35 +0530 Subject: [PATCH 04/41] Add composer update --- .github/workflows/php-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 29f4b164b6..453c017d77 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -50,6 +50,8 @@ jobs: with: node-version-file: '.nvmrc' cache: npm + - name: Composer update + run: composer update - name: npm install run: npm ci - name: Install WordPress From 25921bed66bea28ed575d76ff93cf5cb69856e98 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 9 Dec 2022 15:01:16 +0530 Subject: [PATCH 05/41] Update php-test.yml --- .github/workflows/php-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 453c017d77..1e81135f4b 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -39,7 +39,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['5.6', '7.4', '8.1'] + php: ['7.4','8.0','8.1'] env: WP_ENV_PHP_VERSION: ${{ matrix.php }} steps: From fef535d020176fc9803ccf8470e932c91a87e814 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Mon, 19 Dec 2022 16:43:51 +0530 Subject: [PATCH 06/41] Update package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 6b7da499b1..baf91e8ac5 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "format-php": "wp-env run composer run-script format", "prelint-php": "wp-env run composer 'install --no-interaction'", "lint-php": "wp-env run composer run-script lint", - "pretest-php": "wp-env run composer 'install --no-interaction'", "test-php": "wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/performance/phpunit.xml.dist --verbose'", "pretest-php-multisite": "wp-env run composer 'install --no-interaction'", "test-php-multisite": "wp-env run phpunit 'WP_MULTISITE=1 phpunit -c /var/www/html/wp-content/plugins/performance/tests/multisite.xml --verbose'", From df016d70ce9ac9b256e033a1c259d89dbc2056f0 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 14 Nov 2023 15:11:09 +0100 Subject: [PATCH 07/41] Update matrix --- .github/workflows/php-test.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 2cd12d2e4c..7b761dd0ab 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -39,15 +39,22 @@ on: jobs: php-test: - name: "PHP ${{ matrix.php }}" + name: "PHP ${{ matrix.php }} / WP ${{ matrix.wp }}" runs-on: ubuntu-latest timeout-minutes: 20 strategy: fail-fast: false matrix: - php: ['7.4','8.0','8.1'] + php: ['8.2', '8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0'] + wp: [ 'latest' ] + include: + - php: '7.4' + wp: '6.3' + - php: '8.3' + wp: 'trunk' env: WP_ENV_PHP_VERSION: ${{ matrix.php }} + WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} steps: - uses: styfle/cancel-workflow-action@0.11.0 - uses: actions/checkout@v3 From e8f396dc605ee0c4d8f6453f02fe8c03beac4021 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 14 Nov 2023 15:30:16 +0100 Subject: [PATCH 08/41] Remove php 8.3 again --- .github/workflows/php-test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 7b761dd0ab..f12193f829 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -50,8 +50,6 @@ jobs: include: - php: '7.4' wp: '6.3' - - php: '8.3' - wp: 'trunk' env: WP_ENV_PHP_VERSION: ${{ matrix.php }} WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} From 9c1313740c6d2225dd523b3f35cf09e22034caf8 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 27 Nov 2023 15:20:40 +0100 Subject: [PATCH 09/41] Do not test svg upload --- .../modules/images/dominant-color-images/video-play.svg | 5 ----- tests/utils/TestCase/DominantColorTestCase.php | 3 --- 2 files changed, 8 deletions(-) delete mode 100644 tests/testdata/modules/images/dominant-color-images/video-play.svg diff --git a/tests/testdata/modules/images/dominant-color-images/video-play.svg b/tests/testdata/modules/images/dominant-color-images/video-play.svg deleted file mode 100644 index b5ea206dde..0000000000 --- a/tests/testdata/modules/images/dominant-color-images/video-play.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/tests/utils/TestCase/DominantColorTestCase.php b/tests/utils/TestCase/DominantColorTestCase.php index cb3dbb916a..73dd49a4b5 100644 --- a/tests/utils/TestCase/DominantColorTestCase.php +++ b/tests/utils/TestCase/DominantColorTestCase.php @@ -130,9 +130,6 @@ public function provider_get_dominant_color_invalid_images() { */ public function provider_get_dominant_color_none_images() { return array( - 'svg' => array( - 'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/video-play.svg', - ), 'pdf' => array( 'files_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/wordpress-gsoc-flyer.pdf', ), From 48be5bd5f11226200cd782008be96cffc406c273 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 27 Nov 2023 15:28:44 +0100 Subject: [PATCH 10/41] Make expected color tests a bit more robust --- tests/utils/TestCase/DominantColorTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils/TestCase/DominantColorTestCase.php b/tests/utils/TestCase/DominantColorTestCase.php index 73dd49a4b5..b50757c0ee 100644 --- a/tests/utils/TestCase/DominantColorTestCase.php +++ b/tests/utils/TestCase/DominantColorTestCase.php @@ -14,7 +14,7 @@ public function provider_get_dominant_color() { return array( 'animated_gif' => array( 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/animated.gif', - 'expected_color' => array( '874e4e', 'df7f7f' ), + 'expected_color' => array( '874e4e', '864e4e', 'df7f7f' ), 'expected_transparency' => true, ), 'red_jpg' => array( @@ -97,7 +97,7 @@ public function provider_get_dominant_color() { ), 'balloons_webp' => array( 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp', - 'expected_color' => array( 'c1bbb9', 'c3bdbd' ), + 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c3bdbd' ), 'expected_transparency' => false, ), ); From 41d9e801a3394ff48c878e567e1e97af8f6859d4 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 27 Nov 2023 15:33:28 +0100 Subject: [PATCH 11/41] Add another expected color --- tests/utils/TestCase/DominantColorTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/TestCase/DominantColorTestCase.php b/tests/utils/TestCase/DominantColorTestCase.php index b50757c0ee..6e89a7393e 100644 --- a/tests/utils/TestCase/DominantColorTestCase.php +++ b/tests/utils/TestCase/DominantColorTestCase.php @@ -97,7 +97,7 @@ public function provider_get_dominant_color() { ), 'balloons_webp' => array( 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp', - 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c3bdbd' ), + 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c0bab8', 'c3bdbd' ), 'expected_transparency' => false, ), ); From b58b08f7bba17ee5f8232ec612bbe8155495c2fa Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 5 Dec 2023 13:29:35 +0100 Subject: [PATCH 12/41] Revert "Remove php 8.3 again" This reverts commit e8f396dc605ee0c4d8f6453f02fe8c03beac4021. --- .github/workflows/php-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index f12193f829..7b761dd0ab 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -50,6 +50,8 @@ jobs: include: - php: '7.4' wp: '6.3' + - php: '8.3' + wp: 'trunk' env: WP_ENV_PHP_VERSION: ${{ matrix.php }} WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} From ad1ea1d4d5452b74fa3c13d899b1e3220578472a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 6 Dec 2023 14:33:42 +0100 Subject: [PATCH 13/41] Update wp-env and update deps before tests --- composer.json | 2 +- package-lock.json | 14 +++++++------- package.json | 16 ++++++++-------- tests/multisite.xml | 3 +++ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 8ddca6af09..8f407cd489 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source", "lint": "phpcs --standard=phpcs.xml.dist", "test": "phpunit -c phpunit.xml.dist --verbose", - "test-multisite": "WP_MULTISITE=1 phpunit -c tests/multisite.xml --verbose" + "test-multisite": "phpunit -c tests/multisite.xml --verbose" }, "config": { "allow-plugins": { diff --git a/package-lock.json b/package-lock.json index a324943f09..216ca03b2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "license": "GPL-2.0-or-later", "devDependencies": { "@octokit/rest": "^19.0.5", - "@wordpress/env": "^5.7.0", + "@wordpress/env": "^8.13.0", "@wordpress/scripts": "^24.6.0", "chalk": "^4.1.2", "commander": "^9.4.1", @@ -4366,9 +4366,9 @@ } }, "node_modules/@wordpress/env": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-5.16.0.tgz", - "integrity": "sha512-zx6UO8PuJBrQ34cfeedK1HlGHLFaj7oWzTo9tTt+noB79Ttqc4+a0lYwDqBLLJhlHU+cWgcyOP2lB6TboXH0xA==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-8.13.0.tgz", + "integrity": "sha512-rtrrBO22DnbLsdBlsGqlMQrjz1dZfbwGnxyKev+gFd1rSfmLs+1F8L89RHOx9vsGPixl5uRwoU/qgYo7Hf1NVQ==", "dev": true, "dependencies": { "chalk": "^4.0.0", @@ -21071,9 +21071,9 @@ } }, "@wordpress/env": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-5.16.0.tgz", - "integrity": "sha512-zx6UO8PuJBrQ34cfeedK1HlGHLFaj7oWzTo9tTt+noB79Ttqc4+a0lYwDqBLLJhlHU+cWgcyOP2lB6TboXH0xA==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-8.13.0.tgz", + "integrity": "sha512-rtrrBO22DnbLsdBlsGqlMQrjz1dZfbwGnxyKev+gFd1rSfmLs+1F8L89RHOx9vsGPixl5uRwoU/qgYo7Hf1NVQ==", "dev": true, "requires": { "chalk": "^4.0.0", diff --git a/package.json b/package.json index d88d3f9bf8..a5d266fc74 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "devDependencies": { "@octokit/rest": "^19.0.5", - "@wordpress/env": "^5.7.0", + "@wordpress/env": "^8.13.0", "@wordpress/scripts": "^24.6.0", "chalk": "^4.1.2", "commander": "^9.4.1", @@ -29,14 +29,14 @@ "enabled-modules": "./bin/plugin/cli.js enabled-modules", "format-js": "wp-scripts format ./bin", "lint-js": "wp-scripts lint-js ./bin", - "format-php": "wp-env run composer run-script format", - "phpstan": "wp-env run composer run-script phpstan", + "format-php": "composer format", + "phpstan": "composer phpstan", "prelint-php": "wp-env run composer 'install --no-interaction'", - "lint-php": "wp-env run composer run-script lint", - "pretest-php": "wp-env run composer 'install --no-interaction'", - "test-php": "wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/$(basename $(pwd))/phpunit.xml.dist --verbose'", - "pretest-php-multisite": "wp-env run composer 'install --no-interaction'", - "test-php-multisite": "wp-env run phpunit 'WP_MULTISITE=1 phpunit -c /var/www/html/wp-content/plugins/$(basename $(pwd))/tests/multisite.xml --verbose'", + "lint-php": "composer lint", + "pretest-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction", + "test-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test", + "pretest-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction", + "test-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test-multisite", "wp-env": "wp-env", "prepare": "husky install" }, diff --git a/tests/multisite.xml b/tests/multisite.xml index 271b488b6c..17ec47b055 100644 --- a/tests/multisite.xml +++ b/tests/multisite.xml @@ -6,6 +6,9 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" > + + + ./ From 0b22540f59bca6e155e86ec962db38f30bd5aac2 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 6 Dec 2023 14:34:06 +0100 Subject: [PATCH 14/41] Composer update --- composer.lock | 107 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/composer.lock b/composer.lock index 59e7347f06..a78e0bb6ee 100644 --- a/composer.lock +++ b/composer.lock @@ -532,28 +532,31 @@ }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.3.0", + "version": "v6.4.1", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c" + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c", - "reference": "adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6d6063cf9464a306ca2a0529705d41312b08500b", + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b", "shasum": "" }, "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "nikic/php-parser": "^4.13", "php": "^7.4 || ~8.0.0", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.3", "phpstan/phpstan": "^1.10.12", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" }, "suggest": { "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" }, "type": "library", @@ -570,9 +573,9 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.3.0" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.4.1" }, - "time": "2023-08-10T16:34:11+00:00" + "time": "2023-11-10T00:33:47+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -638,16 +641,16 @@ }, { "name": "phpcsstandards/phpcsextra", - "version": "1.1.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "746c3190ba8eb2f212087c947ba75f4f5b9a58d5" + "reference": "78b2cae1e9de1c05f0416de6f9a658cbb83ac324" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/746c3190ba8eb2f212087c947ba75f4f5b9a58d5", - "reference": "746c3190ba8eb2f212087c947ba75f4f5b9a58d5", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/78b2cae1e9de1c05f0416de6f9a658cbb83ac324", + "reference": "78b2cae1e9de1c05f0416de6f9a658cbb83ac324", "shasum": "" }, "require": { @@ -695,9 +698,24 @@ ], "support": { "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", "source": "https://github.com/PHPCSStandards/PHPCSExtra" }, - "time": "2023-09-20T22:06:18+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-02T14:30:12+00:00" }, { "name": "phpcsstandards/phpcsutils", @@ -818,16 +836,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.2", + "version": "1.24.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "bcad8d995980440892759db0c32acae7c8e79442" + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", - "reference": "bcad8d995980440892759db0c32acae7c8e79442", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", "shasum": "" }, "require": { @@ -859,22 +877,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.4" }, - "time": "2023-09-26T12:28:12+00:00" + "time": "2023-11-26T18:29:22+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.38", + "version": "1.10.47", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691" + "reference": "84dbb33b520ea28b6cf5676a3941f4bae1c1ff39" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5302bb402c57f00fb3c2c015bac86e0827e4b691", - "reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/84dbb33b520ea28b6cf5676a3941f4bae1c1ff39", + "reference": "84dbb33b520ea28b6cf5676a3941f4bae1c1ff39", "shasum": "" }, "require": { @@ -923,7 +941,7 @@ "type": "tidelift" } ], - "time": "2023-10-06T14:19:14+00:00" + "time": "2023-12-01T15:19:17+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -1346,16 +1364,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.13", + "version": "9.6.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" + "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", - "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/05017b80304e0eb3f31d90194a563fd53a6021f1", + "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1", "shasum": "" }, "require": { @@ -1429,7 +1447,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.15" }, "funding": [ { @@ -1445,7 +1463,7 @@ "type": "tidelift" } ], - "time": "2023-09-19T05:39:22+00:00" + "time": "2023-12-01T16:55:19+00:00" }, { "name": "sebastian/cli-parser", @@ -2614,22 +2632,22 @@ }, { "name": "szepeviktor/phpstan-wordpress", - "version": "v1.3.0", + "version": "v1.3.2", "source": { "type": "git", "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9" + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9", - "reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/b8516ed6bab7ec50aae981698ce3f67f1be2e45a", + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", - "phpstan/phpstan": "^1.10.0", + "phpstan/phpstan": "^1.10.30", "symfony/polyfill-php73": "^1.12.0" }, "require-dev": { @@ -2640,6 +2658,9 @@ "phpunit/phpunit": "^8.0 || ^9.0", "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" }, + "suggest": { + "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" + }, "type": "phpstan-extension", "extra": { "phpstan": { @@ -2667,22 +2688,22 @@ ], "support": { "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", - "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.0" + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.2" }, - "time": "2023-04-23T06:15:06+00:00" + "time": "2023-10-16T17:23:56+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", "shasum": "" }, "require": { @@ -2711,7 +2732,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" }, "funding": [ { @@ -2719,7 +2740,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2023-11-20T00:12:19+00:00" }, { "name": "wp-coding-standards/wpcs", @@ -2789,7 +2810,7 @@ }, { "name": "wp-phpunit/wp-phpunit", - "version": "5.9.7", + "version": "5.9.8", "source": { "type": "git", "url": "https://github.com/wp-phpunit/wp-phpunit.git", From c91391326e4f3520a8e9f4cc9f8789db066d230c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 6 Dec 2023 15:01:29 +0100 Subject: [PATCH 15/41] Improve assertions to make tests a bit more robust --- .../dominant-color-image-editor-gd-test.php | 1 + .../dominant-color-image-editor-imageick-test.php | 2 ++ tests/modules/images/webp-uploads/helper-tests.php | 2 ++ tests/modules/images/webp-uploads/load-tests.php | 1 + 4 files changed, 6 insertions(+) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php index 5d4188bc62..4921313459 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php @@ -35,6 +35,7 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected $dominant_color_data = dominant_color_get_dominant_color_data( $attachment_id ); + $this->assertNotWPError( $dominant_color_data ); $this->assertContains( $dominant_color_data['dominant_color'], $expected_color ); $this->assertSame( $dominant_color_data['has_transparency'], $expected_transparency ); } diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php index b4ceecb51a..4ad97d360a 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php @@ -37,6 +37,7 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected $dominant_color_data = dominant_color_get_dominant_color_data( $attachment_id ); + $this->assertNotWPError( $dominant_color_data ); $this->assertContains( $dominant_color_data['dominant_color'], $expected_color ); $this->assertSame( $dominant_color_data['has_transparency'], $expected_transparency ); } @@ -57,6 +58,7 @@ public function test_get_dominant_color_invalid( $image_path, $expected_color, $ $dominant_color_data = dominant_color_get_dominant_color_data( $attachment_id ); + $this->assertNotWPError( $dominant_color_data ); $this->assertContains( $dominant_color_data['dominant_color'], $expected_color ); $this->assertSame( $dominant_color_data['has_transparency'], $expected_transparency ); } diff --git a/tests/modules/images/webp-uploads/helper-tests.php b/tests/modules/images/webp-uploads/helper-tests.php index a4ebe0dd58..1bbe328a1a 100644 --- a/tests/modules/images/webp-uploads/helper-tests.php +++ b/tests/modules/images/webp-uploads/helper-tests.php @@ -94,6 +94,7 @@ public function it_should_create_an_image_with_the_default_suffix_in_the_same_lo $directory = trailingslashit( pathinfo( $file, PATHINFO_DIRNAME ) ); $name = pathinfo( $file, PATHINFO_FILENAME ); + $this->assertNotWPError( $result ); $this->assertIsArray( $result ); $this->assertArrayHasKey( 'filesize', $result ); $this->assertArrayHasKey( 'file', $result ); @@ -116,6 +117,7 @@ public function it_should_create_a_file_in_the_specified_location_with_the_speci $result = webp_uploads_generate_additional_image_source( $attachment_id, 'medium', $size_data, 'image/webp', '/tmp/image.jpg' ); + $this->assertNotWPError( $result ); $this->assertIsArray( $result ); $this->assertArrayHasKey( 'filesize', $result ); $this->assertArrayHasKey( 'file', $result ); diff --git a/tests/modules/images/webp-uploads/load-tests.php b/tests/modules/images/webp-uploads/load-tests.php index 7251b4aced..0a315806d2 100644 --- a/tests/modules/images/webp-uploads/load-tests.php +++ b/tests/modules/images/webp-uploads/load-tests.php @@ -646,6 +646,7 @@ static function () { continue; } + $this->assertIsString( $size['sources']['image/webp']['file'] ); $this->assertStringContainsString( $size['width'], $size['sources']['image/webp']['file'] ); $this->assertStringContainsString( $size['height'], $size['sources']['image/webp']['file'] ); $this->assertStringContainsString( From fe1ba5b79ecb0cfa8f158dfebad101c7d22824cd Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 6 Dec 2023 15:46:00 +0100 Subject: [PATCH 16/41] Split out phpstan into its own composer.json --- .gitignore | 2 + build-cs/composer.json | 14 ++ composer.json | 10 +- composer.lock | 396 +---------------------------------------- phpstan.neon.dist | 2 +- 5 files changed, 22 insertions(+), 402 deletions(-) create mode 100644 build-cs/composer.json diff --git a/.gitignore b/.gitignore index 1889d02de2..02b6696654 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ nbproject/ build .wp-env.override.json +build-cs/vendor/ +build-cs/composer.lock ############ ## Vendor diff --git a/build-cs/composer.json b/build-cs/composer.json new file mode 100644 index 0000000000..a88ba2a29e --- /dev/null +++ b/build-cs/composer.json @@ -0,0 +1,14 @@ +{ + "require-dev": { + "phpstan/extension-installer": "^1.3.0", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan-deprecation-rules": "^1.1", + "szepeviktor/phpstan-wordpress": "^1.3.0" + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } + } +} diff --git a/composer.json b/composer.json index 8f407cd489..aca2b50c29 100644 --- a/composer.json +++ b/composer.json @@ -14,15 +14,10 @@ "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7", "phpcompatibility/php-compatibility": "^9.3", - "phpstan/extension-installer": "^1.3.0", - "phpstan/phpstan": "^1.10", "squizlabs/php_codesniffer": "^3.5", - "szepeviktor/phpstan-wordpress": "^1.3.0", "wp-coding-standards/wpcs": "^3.0.0", "wp-phpunit/wp-phpunit": "^5.8", "yoast/phpunit-polyfills": "^1.0", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/phpstan-deprecation-rules": "^1.1", "slevomat/coding-standard": "^8.0" }, "require": { @@ -30,7 +25,10 @@ "php": ">=7|^8" }, "scripts": { - "phpstan": "phpstan analyze --ansi --memory-limit=2048M", + "phpstan": [ + "composer --working-dir=build-cs update --no-interaction", + "build-cs/vendor/bin/phpstan analyse --memory-limit=2048M -c phpstan.neon.dist" + ], "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source", "lint": "phpcs --standard=phpcs.xml.dist", "test": "phpunit -c phpunit.xml.dist --verbose", diff --git a/composer.lock b/composer.lock index a78e0bb6ee..688d4ecd79 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8afb8511538e46c6875a017b72ad8711", + "content-hash": "1de45d8c347d30cac1076a5ecc3a09c5", "packages": [ { "name": "composer/installers", @@ -530,53 +530,6 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "php-stubs/wordpress-stubs", - "version": "v6.4.1", - "source": { - "type": "git", - "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "6d6063cf9464a306ca2a0529705d41312b08500b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6d6063cf9464a306ca2a0529705d41312b08500b", - "reference": "6d6063cf9464a306ca2a0529705d41312b08500b", - "shasum": "" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "nikic/php-parser": "^4.13", - "php": "^7.4 || ~8.0.0", - "php-stubs/generator": "^0.8.3", - "phpdocumentor/reflection-docblock": "^5.3", - "phpstan/phpstan": "^1.10.12", - "phpunit/phpunit": "^9.5", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" - }, - "suggest": { - "paragonie/sodium_compat": "Pure PHP implementation of libsodium", - "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "WordPress function and class declaration stubs for static analysis.", - "homepage": "https://github.com/php-stubs/wordpress-stubs", - "keywords": [ - "PHPStan", - "static analysis", - "wordpress" - ], - "support": { - "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.4.1" - }, - "time": "2023-11-10T00:33:47+00:00" - }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -790,50 +743,6 @@ }, "time": "2023-07-16T21:39:41+00:00" }, - { - "name": "phpstan/extension-installer", - "version": "1.3.1", - "source": { - "type": "git", - "url": "https://github.com/phpstan/extension-installer.git", - "reference": "f45734bfb9984c6c56c4486b71230355f066a58a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f45734bfb9984c6c56c4486b71230355f066a58a", - "reference": "f45734bfb9984c6c56c4486b71230355f066a58a", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^2.0", - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.9.0" - }, - "require-dev": { - "composer/composer": "^2.0", - "php-parallel-lint/php-parallel-lint": "^1.2.0", - "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" - }, - "type": "composer-plugin", - "extra": { - "class": "PHPStan\\ExtensionInstaller\\Plugin" - }, - "autoload": { - "psr-4": { - "PHPStan\\ExtensionInstaller\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Composer plugin for automatic installation of PHPStan extensions", - "support": { - "issues": "https://github.com/phpstan/extension-installer/issues", - "source": "https://github.com/phpstan/extension-installer/tree/1.3.1" - }, - "time": "2023-05-24T08:59:17+00:00" - }, { "name": "phpstan/phpdoc-parser", "version": "1.24.4", @@ -881,168 +790,6 @@ }, "time": "2023-11-26T18:29:22+00:00" }, - { - "name": "phpstan/phpstan", - "version": "1.10.47", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "84dbb33b520ea28b6cf5676a3941f4bae1c1ff39" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/84dbb33b520ea28b6cf5676a3941f4bae1c1ff39", - "reference": "84dbb33b520ea28b6cf5676a3941f4bae1c1ff39", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" - } - ], - "time": "2023-12-01T15:19:17+00:00" - }, - { - "name": "phpstan/phpstan-deprecation-rules", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa", - "reference": "089d8a8258ed0aeefdc7b68b6c3d25572ebfdbaa", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.3" - }, - "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-php-parser": "^1.1", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", - "support": { - "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.1.4" - }, - "time": "2023-08-05T09:02:04+00:00" - }, - { - "name": "phpstan/phpstan-phpunit", - "version": "1.3.15", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "70ecacc64fe8090d8d2a33db5a51fe8e88acd93a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/70ecacc64fe8090d8d2a33db5a51fe8e88acd93a", - "reference": "70ecacc64fe8090d8d2a33db5a51fe8e88acd93a", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10" - }, - "conflict": { - "phpunit/phpunit": "<7.0" - }, - "require-dev": { - "nikic/php-parser": "^4.13.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "extension.neon", - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPUnit extensions and rules for PHPStan", - "support": { - "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.15" - }, - "time": "2023-10-09T18:58:39+00:00" - }, { "name": "phpunit/php-code-coverage", "version": "9.2.29", @@ -2551,147 +2298,6 @@ }, "time": "2023-02-22T23:07:41+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.28.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-01-26T09:26:14+00:00" - }, - { - "name": "szepeviktor/phpstan-wordpress", - "version": "v1.3.2", - "source": { - "type": "git", - "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/b8516ed6bab7ec50aae981698ce3f67f1be2e45a", - "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", - "phpstan/phpstan": "^1.10.30", - "symfony/polyfill-php73": "^1.12.0" - }, - "require-dev": { - "composer/composer": "^2.1.14", - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.1", - "phpstan/phpstan-strict-rules": "^1.2", - "phpunit/phpunit": "^8.0 || ^9.0", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" - }, - "suggest": { - "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "SzepeViktor\\PHPStan\\WordPress\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "WordPress extensions for PHPStan", - "keywords": [ - "PHPStan", - "code analyse", - "code analysis", - "static analysis", - "wordpress" - ], - "support": { - "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", - "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.2" - }, - "time": "2023-10-16T17:23:56+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.2", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a25d2d4cf4..2b6e1848a2 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,5 @@ includes: - - phar://phpstan.phar/conf/bleedingEdge.neon + - build-cs/vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: level: 0 paths: From f214c6903cdffd58bedbd8ab3c3afa600c0b6f31 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 6 Dec 2023 16:33:41 +0100 Subject: [PATCH 17/41] Split out PHPCS as well `slevomat/coding-standard` requires PHP 7.2+ --- build-cs/composer.json | 10 +- composer.json | 21 +- composer.lock | 525 +---------------------------------------- 3 files changed, 20 insertions(+), 536 deletions(-) diff --git a/build-cs/composer.json b/build-cs/composer.json index a88ba2a29e..d75d3943f6 100644 --- a/build-cs/composer.json +++ b/build-cs/composer.json @@ -1,13 +1,19 @@ { "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "phpcompatibility/php-compatibility": "^9.3", "phpstan/extension-installer": "^1.3.0", "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-deprecation-rules": "^1.1", - "szepeviktor/phpstan-wordpress": "^1.3.0" + "phpstan/phpstan-phpunit": "^1.3", + "slevomat/coding-standard": "^8.0", + "squizlabs/php_codesniffer": "^3.5", + "szepeviktor/phpstan-wordpress": "^1.3.0", + "wp-coding-standards/wpcs": "^3.0.0" }, "config": { "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, "phpstan/extension-installer": true } } diff --git a/composer.json b/composer.json index aca2b50c29..f2071e17e7 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,8 @@ "issues": "https://github.com/WordPress/performance/issues" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "phpcompatibility/php-compatibility": "^9.3", - "squizlabs/php_codesniffer": "^3.5", - "wp-coding-standards/wpcs": "^3.0.0", "wp-phpunit/wp-phpunit": "^5.8", - "yoast/phpunit-polyfills": "^1.0", - "slevomat/coding-standard": "^8.0" + "yoast/phpunit-polyfills": "^1.0" }, "require": { "composer/installers": "~1.0", @@ -29,16 +24,22 @@ "composer --working-dir=build-cs update --no-interaction", "build-cs/vendor/bin/phpstan analyse --memory-limit=2048M -c phpstan.neon.dist" ], - "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source", - "lint": "phpcs --standard=phpcs.xml.dist", + "format": [ + "composer --working-dir=build-cs update --no-interaction", + "build-cs/vendor/bin/phpcbf --standard=phpcs.xml.dist --report-summary --report-source" + ], + "lint": [ + "composer --working-dir=build-cs update --no-interaction", + "build-cs/vendor/bin/phpcs --standard=phpcs.xml.dist" + ], "test": "phpunit -c phpunit.xml.dist --verbose", "test-multisite": "phpunit -c tests/multisite.xml --verbose" }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true, "composer/installers": true, - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true } }, "autoload-dev": { diff --git a/composer.lock b/composer.lock index 688d4ecd79..765b666dda 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1de45d8c347d30cac1076a5ecc3a09c5", + "content-hash": "bd9b816ae7c15eb36b10d97e807a6ce2", "packages": [ { "name": "composer/installers", @@ -159,81 +159,6 @@ } ], "packages-dev": [ - { - "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", - "source": { - "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" - }, - "require-dev": { - "composer/composer": "*", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" - }, - "type": "composer-plugin", - "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" - }, - "autoload": { - "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" - }, - { - "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" - } - ], - "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", - "keywords": [ - "PHPCodeSniffer", - "PHP_CodeSniffer", - "code quality", - "codesniffer", - "composer", - "installer", - "phpcbf", - "phpcs", - "plugin", - "qa", - "quality", - "standard", - "standards", - "style guide", - "stylecheck", - "tests" - ], - "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" - }, - "time": "2022-02-04T12:51:07+00:00" - }, { "name": "doctrine/instantiator", "version": "2.0.0", @@ -530,266 +455,6 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "phpcompatibility/php-compatibility", - "version": "9.3.5", - "source": { - "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." - }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ - { - "name": "Wim Godden", - "homepage": "https://github.com/wimg", - "role": "lead" - }, - { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", - "role": "lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" - } - ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", - "keywords": [ - "compatibility", - "phpcs", - "standards" - ], - "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibility" - }, - "time": "2019-12-27T09:44:58+00:00" - }, - { - "name": "phpcsstandards/phpcsextra", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "78b2cae1e9de1c05f0416de6f9a658cbb83ac324" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/78b2cae1e9de1c05f0416de6f9a658cbb83ac324", - "reference": "78b2cae1e9de1c05f0416de6f9a658cbb83ac324", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.8", - "squizlabs/php_codesniffer": "^3.7.1" - }, - "require-dev": { - "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", - "phpcsstandards/phpcsdevtools": "^1.2.1", - "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0" - }, - "type": "phpcodesniffer-standard", - "extra": { - "branch-alias": { - "dev-stable": "1.x-dev", - "dev-develop": "1.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ - { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", - "role": "lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" - } - ], - "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", - "keywords": [ - "PHP_CodeSniffer", - "phpcbf", - "phpcodesniffer-standard", - "phpcs", - "standards", - "static analysis" - ], - "support": { - "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", - "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", - "source": "https://github.com/PHPCSStandards/PHPCSExtra" - }, - "funding": [ - { - "url": "https://github.com/PHPCSStandards", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", - "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" - } - ], - "time": "2023-12-02T14:30:12+00:00" - }, - { - "name": "phpcsstandards/phpcsutils", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/69465cab9d12454e5e7767b9041af0cd8cd13be7", - "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7", - "shasum": "" - }, - "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", - "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.7.1 || 4.0.x-dev@dev" - }, - "require-dev": { - "ext-filter": "*", - "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcsstandards/phpcsdevcs": "^1.1.6", - "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0" - }, - "type": "phpcodesniffer-standard", - "extra": { - "branch-alias": { - "dev-stable": "1.x-dev", - "dev-develop": "1.x-dev" - } - }, - "autoload": { - "classmap": [ - "PHPCSUtils/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ - { - "name": "Juliette Reinders Folmer", - "homepage": "https://github.com/jrfnl", - "role": "lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" - } - ], - "description": "A suite of utility functions for use with PHP_CodeSniffer", - "homepage": "https://phpcsutils.com/", - "keywords": [ - "PHP_CodeSniffer", - "phpcbf", - "phpcodesniffer-standard", - "phpcs", - "phpcs3", - "standards", - "static analysis", - "tokens", - "utility" - ], - "support": { - "docs": "https://phpcsutils.com/", - "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", - "source": "https://github.com/PHPCSStandards/PHPCSUtils" - }, - "time": "2023-07-16T21:39:41+00:00" - }, - { - "name": "phpstan/phpdoc-parser", - "version": "1.24.4", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^4.15", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", - "symfony/process": "^5.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "support": { - "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.4" - }, - "time": "2023-11-26T18:29:22+00:00" - }, { "name": "phpunit/php-code-coverage", "version": "9.2.29", @@ -2176,128 +1841,6 @@ ], "time": "2020-09-28T06:39:44+00:00" }, - { - "name": "slevomat/coding-standard", - "version": "8.14.1", - "source": { - "type": "git", - "url": "https://github.com/slevomat/coding-standard.git", - "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/fea1fd6f137cc84f9cba0ae30d549615dbc6a926", - "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926", - "shasum": "" - }, - "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", - "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.23.1", - "squizlabs/php_codesniffer": "^3.7.1" - }, - "require-dev": { - "phing/phing": "2.17.4", - "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.37", - "phpstan/phpstan-deprecation-rules": "1.1.4", - "phpstan/phpstan-phpunit": "1.3.14", - "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "8.5.21|9.6.8|10.3.5" - }, - "type": "phpcodesniffer-standard", - "extra": { - "branch-alias": { - "dev-master": "8.x-dev" - } - }, - "autoload": { - "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", - "keywords": [ - "dev", - "phpcs" - ], - "support": { - "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.14.1" - }, - "funding": [ - { - "url": "https://github.com/kukulich", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", - "type": "tidelift" - } - ], - "time": "2023-10-08T07:28:08+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.7.2", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards", - "static analysis" - ], - "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" - }, - "time": "2023-02-22T23:07:41+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.2", @@ -2348,72 +1891,6 @@ ], "time": "2023-11-20T00:12:19+00:00" }, - { - "name": "wp-coding-standards/wpcs", - "version": "3.0.1", - "source": { - "type": "git", - "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b4caf9689f1a0e4a4c632679a44e638c1c67aff1", - "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "ext-libxml": "*", - "ext-tokenizer": "*", - "ext-xmlreader": "*", - "php": ">=5.4", - "phpcsstandards/phpcsextra": "^1.1.0", - "phpcsstandards/phpcsutils": "^1.0.8", - "squizlabs/php_codesniffer": "^3.7.2" - }, - "require-dev": { - "php-parallel-lint/php-console-highlighter": "^1.0.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.2.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "suggest": { - "ext-iconv": "For improved results", - "ext-mbstring": "For improved results" - }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Contributors", - "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" - } - ], - "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", - "keywords": [ - "phpcs", - "standards", - "static analysis", - "wordpress" - ], - "support": { - "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", - "source": "https://github.com/WordPress/WordPress-Coding-Standards", - "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" - }, - "funding": [ - { - "url": "https://opencollective.com/thewpcc/contribute/wp-php-63406", - "type": "custom" - } - ], - "time": "2023-09-14T07:06:09+00:00" - }, { "name": "wp-phpunit/wp-phpunit", "version": "5.9.8", From 65f15b01e86c20075ad13e3092bae8eebe7fe8f8 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 7 Dec 2023 11:23:57 +0100 Subject: [PATCH 18/41] Skip tests if extension is missing --- .../dominant-color-image-editor-imageick-test.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php index 4ad97d360a..7f118bbc86 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php @@ -31,6 +31,9 @@ static function () { * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ public function test_get_dominant_color( $image_path, $expected_color, $expected_transparency ) { + if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) ) { + $this->markTestSkipped( 'The Imagick PHP extension is not loaded.' ); + } $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); @@ -52,6 +55,9 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ public function test_get_dominant_color_invalid( $image_path, $expected_color, $expected_transparency ) { + if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) ) { + $this->markTestSkipped( 'The Imagick PHP extension is not loaded.' ); + } $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); @@ -71,6 +77,9 @@ public function test_get_dominant_color_invalid( $image_path, $expected_color, $ * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ public function test_get_dominant_color_none_images( $image_path ) { + if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) ) { + $this->markTestSkipped( 'The Imagick PHP extension is not loaded.' ); + } $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); From 96e63dc82e370e9a9bee32863ef86530f40704fc Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 7 Dec 2023 11:24:52 +0100 Subject: [PATCH 19/41] Fix typo in class name --- ...ck-test.php => dominant-color-image-editor-imagick-test.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/modules/images/dominant-color-images/{dominant-color-image-editor-imageick-test.php => dominant-color-image-editor-imagick-test.php} (97%) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php similarity index 97% rename from tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php rename to tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php index 7f118bbc86..6a4af258b8 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php @@ -10,7 +10,7 @@ use PerformanceLab\Tests\TestCase\DominantColorTestCase; -class Dominant_Color_Image_Editor_Imageick_Test extends DominantColorTestCase { +class Dominant_Color_Image_Editor_Imagick_Test extends DominantColorTestCase { public function set_up() { parent::set_up(); // TODO: Change the autogenerated stub. From 68cf970fe142fc10bd27126f7a4f9fccfddd6782 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 7 Dec 2023 11:38:48 +0100 Subject: [PATCH 20/41] Add same checks to GD tests --- .../dominant-color-image-editor-gd-test.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php index 4921313459..db53fe08c9 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php @@ -29,6 +29,9 @@ static function () { * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ public function test_get_dominant_color( $image_path, $expected_color, $expected_transparency ) { + if ( ! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) ) { + $this->markTestSkipped( 'The GD PHP extension is not loaded.' ); + } $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); @@ -50,6 +53,9 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ public function test_get_dominant_color_invalid( $image_path, $expected_color, $expected_transparency ) { + if ( ! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) ) { + $this->markTestSkipped( 'The GD PHP extension is not loaded.' ); + } $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); @@ -68,6 +74,9 @@ public function test_get_dominant_color_invalid( $image_path, $expected_color, $ * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ public function test_get_dominant_color_none_images( $image_path ) { + if ( ! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) ) { + $this->markTestSkipped( 'The GD PHP extension is not loaded.' ); + } $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); From 714549723c5b1172c7f8e62bf450038325af4e4a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 23 Jan 2024 10:41:34 +0100 Subject: [PATCH 21/41] Remove hardcoded `phpVersion` --- .wp-env.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.wp-env.json b/.wp-env.json index 9af20e97ab..673c3bd542 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -5,8 +5,7 @@ "tests": { "config": { "FS_METHOD": "direct" - }, - "phpVersion": "7.4" + } } } } From baf7ce31678f73115b6ea4d8f00c7b42f8340c7b Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Tue, 23 Jan 2024 17:04:31 +0530 Subject: [PATCH 22/41] Temp: Remove filter and adjust test --- .../dominant-color-image-editor-gd-test.php | 11 ----------- .../dominant-color-image-editor-imagick-test.php | 11 ----------- .../modules/images/webp-uploads/image-edit-tests.php | 4 ++++ 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php index db53fe08c9..680337b8ed 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php @@ -9,17 +9,6 @@ use PerformanceLab\Tests\TestCase\DominantColorTestCase; class Dominant_Color_Image_Editor_GD_Test extends DominantColorTestCase { - public function set_up() { - parent::set_up(); // TODO: Change the autogenerated stub. - - add_filter( - 'wp_image_editors', - static function () { - return array( 'Dominant_Color_Image_Editor_GD' ); - }, - 100 - ); - } /** * Test if the function returns the correct color. diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php index 6a4af258b8..a020cfb173 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php @@ -11,17 +11,6 @@ use PerformanceLab\Tests\TestCase\DominantColorTestCase; class Dominant_Color_Image_Editor_Imagick_Test extends DominantColorTestCase { - public function set_up() { - parent::set_up(); // TODO: Change the autogenerated stub. - - add_filter( - 'wp_image_editors', - static function () { - return array( 'Dominant_Color_Image_Editor_Imagick' ); - }, - 100 - ); - } /** * Test if the function returns the correct color. diff --git a/tests/modules/images/webp-uploads/image-edit-tests.php b/tests/modules/images/webp-uploads/image-edit-tests.php index 80b1ec5cdb..c229133e86 100644 --- a/tests/modules/images/webp-uploads/image-edit-tests.php +++ b/tests/modules/images/webp-uploads/image-edit-tests.php @@ -302,6 +302,10 @@ static function () { * @test */ public function it_should_validate_source_attribute_update_when_webp_edited() { + if ( ! webp_uploads_image_edit_thumbnails_separately() ) { + $this->markTestSkipped( 'Editing image thumbnails separately is disabled' ); + } + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leafs.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); From 533e371c2d30d2ec343b6a86e9925acb0a055e70 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 24 Jan 2024 16:48:13 +0530 Subject: [PATCH 23/41] Correct Dominant Color tests --- .../dominant-color-image-editor-gd-test.php | 2 +- .../dominant-color-image-editor-imagick-test.php | 7 +++---- tests/utils/TestCase/DominantColorTestCase.php | 8 ++------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php index 680337b8ed..71768a8f7a 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php @@ -41,7 +41,7 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected * * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ - public function test_get_dominant_color_invalid( $image_path, $expected_color, $expected_transparency ) { + public function test_get_dominant_color_invalid( $image_path ) { if ( ! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) ) { $this->markTestSkipped( 'The GD PHP extension is not loaded.' ); } diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php index a020cfb173..98a55ae863 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php @@ -43,7 +43,7 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected * * @covers Dominant_Color_Image_Editor_GD::get_dominant_color */ - public function test_get_dominant_color_invalid( $image_path, $expected_color, $expected_transparency ) { + public function test_get_dominant_color_invalid( $image_path ) { if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) ) { $this->markTestSkipped( 'The Imagick PHP extension is not loaded.' ); } @@ -53,9 +53,8 @@ public function test_get_dominant_color_invalid( $image_path, $expected_color, $ $dominant_color_data = dominant_color_get_dominant_color_data( $attachment_id ); - $this->assertNotWPError( $dominant_color_data ); - $this->assertContains( $dominant_color_data['dominant_color'], $expected_color ); - $this->assertSame( $dominant_color_data['has_transparency'], $expected_transparency ); + $this->assertWPError( $dominant_color_data ); + $this->assertStringContainsString( 'image_no_editor', $dominant_color_data->get_error_code() ); } /** diff --git a/tests/utils/TestCase/DominantColorTestCase.php b/tests/utils/TestCase/DominantColorTestCase.php index 6e89a7393e..9e401db6a2 100644 --- a/tests/utils/TestCase/DominantColorTestCase.php +++ b/tests/utils/TestCase/DominantColorTestCase.php @@ -111,14 +111,10 @@ public function provider_get_dominant_color() { public function provider_get_dominant_color_invalid_images() { return array( 'tiff' => array( - 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/test-image.tiff', - 'expected_color' => array( 'dfdfdf' ), - 'expected_transparency' => true, + 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/test-image.tiff', ), 'bmp' => array( - 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/test-image.bmp', - 'expected_color' => array( 'dfdfdf' ), - 'expected_transparency' => true, + 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dominant-color-images/test-image.bmp', ), ); } From e2872b8779347e862b97bc551d070f7f3cb78bbc Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 24 Jan 2024 17:41:39 +0530 Subject: [PATCH 24/41] Add color option for PHP7.2 --- tests/utils/TestCase/DominantColorTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/TestCase/DominantColorTestCase.php b/tests/utils/TestCase/DominantColorTestCase.php index 9e401db6a2..0012976dd9 100644 --- a/tests/utils/TestCase/DominantColorTestCase.php +++ b/tests/utils/TestCase/DominantColorTestCase.php @@ -97,7 +97,7 @@ public function provider_get_dominant_color() { ), 'balloons_webp' => array( 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp', - 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c0bab8', 'c3bdbd' ), + 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c0bab8', 'c3bdbd', 'bfbab8' ), 'expected_transparency' => false, ), ); From 705add678a90ad75735b25da1659b35730be2ed6 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 24 Jan 2024 14:37:05 +0100 Subject: [PATCH 25/41] Skip WebP tests if there is no WebP support --- .../dominant-color-image-editor-gd-test.php | 5 +++++ .../dominant-color-test.php | 10 ++++++++++ .../modules/images/webp-uploads/helper-tests.php | 16 ++++++++++++++++ .../images/webp-uploads/image-edit-tests.php | 4 ++++ tests/modules/images/webp-uploads/load-tests.php | 4 ++++ 5 files changed, 39 insertions(+) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php index 71768a8f7a..3ce2a52f79 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php @@ -22,6 +22,11 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected $this->markTestSkipped( 'The GD PHP extension is not loaded.' ); } + $mime_type = wp_check_filetype( $image_path )['type']; + if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) { + $this->markTestSkipped( "Mime type $mime_type is not supported." ); + } + $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); diff --git a/tests/modules/images/dominant-color-images/dominant-color-test.php b/tests/modules/images/dominant-color-images/dominant-color-test.php index 02ebf80dc1..def232fef4 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-test.php @@ -70,6 +70,11 @@ public function test_has_transparency_metadata( $image_path, $expected_color, $e * @covers ::dominant_color_get_dominant_color */ public function test_dominant_color_has_transparency( $image_path, $expected_color, $expected_transparency ) { + $mime_type = wp_check_filetype( $image_path )['type']; + if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) { + $this->markTestSkipped( "Mime type $mime_type is not supported." ); + } + // Creating attachment. $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); $this->assertSame( $expected_transparency, dominant_color_has_transparency( $attachment_id ) ); @@ -83,6 +88,11 @@ public function test_dominant_color_has_transparency( $image_path, $expected_col * @covers ::dominant_color_img_tag_add_dominant_color */ public function test_tag_add_adjust_to_image_attributes( $image_path, $expected_color, $expected_transparency ) { + $mime_type = wp_check_filetype( $image_path )['type']; + if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) { + $this->markTestSkipped( "Mime type $mime_type is not supported." ); + } + $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); diff --git a/tests/modules/images/webp-uploads/helper-tests.php b/tests/modules/images/webp-uploads/helper-tests.php index a37d440694..ec00843a0b 100644 --- a/tests/modules/images/webp-uploads/helper-tests.php +++ b/tests/modules/images/webp-uploads/helper-tests.php @@ -79,6 +79,10 @@ public function data_provider_invalid_arguments_for_webp_uploads_generate_additi * @test */ public function it_should_create_an_image_with_the_default_suffix_in_the_same_location_when_no_destination_is_specified() { + if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { + $this->markTestSkipped( 'Mime type image/webp is not supported.' ); + } + // Create JPEG and WebP so that both versions are generated. $this->opt_in_to_jpeg_and_webp(); @@ -108,6 +112,10 @@ public function it_should_create_an_image_with_the_default_suffix_in_the_same_lo * @test */ public function it_should_create_a_file_in_the_specified_location_with_the_specified_name() { + if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { + $this->markTestSkipped( 'Mime type image/webp is not supported.' ); + } + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); $size_data = array( 'width' => 300, @@ -177,6 +185,10 @@ static function ( $metadata ) { * @test */ public function it_should_prevent_to_create_an_image_size_when_attached_file_does_not_exists() { + if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { + $this->markTestSkipped( 'Mime type image/webp is not supported.' ); + } + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leafs.jpg' ); @@ -545,6 +557,10 @@ private function mock_empty_action( $action ) { * @test */ public function it_should_add_original_image_extension_to_the_webp_file_name_to_ensure_it_is_unique( $jpeg_image, $jpg_image ) { + if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { + $this->markTestSkipped( 'Mime type image/webp is not supported.' ); + } + $jpeg_image_attachment_id = self::factory()->attachment->create_upload_object( $jpeg_image ); $jpg_image_attachment_id = self::factory()->attachment->create_upload_object( $jpg_image ); diff --git a/tests/modules/images/webp-uploads/image-edit-tests.php b/tests/modules/images/webp-uploads/image-edit-tests.php index c229133e86..3ba75f8008 100644 --- a/tests/modules/images/webp-uploads/image-edit-tests.php +++ b/tests/modules/images/webp-uploads/image-edit-tests.php @@ -64,6 +64,10 @@ public function it_should_backup_the_sources_structure_alongside_the_full_size() * @test */ public function it_should_restore_the_sources_array_from_the_backup_when_an_image_is_edited() { + if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { + $this->markTestSkipped( 'Mime type image/webp is not supported.' ); + } + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leafs.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); diff --git a/tests/modules/images/webp-uploads/load-tests.php b/tests/modules/images/webp-uploads/load-tests.php index bca5bf5c0d..624762adab 100644 --- a/tests/modules/images/webp-uploads/load-tests.php +++ b/tests/modules/images/webp-uploads/load-tests.php @@ -21,6 +21,10 @@ public function set_up() { parent::set_up(); add_filter( 'webp_uploads_discard_larger_generated_images', '__return_false' ); + + if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { + $this->markTestSkipped( 'Mime type image/webp is not supported.' ); + } } public function tear_down() { From bd54d04bb60d912363e715794a3e557b6b99f650 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 24 Jan 2024 14:42:30 +0100 Subject: [PATCH 26/41] Update more tests --- .../dominant-color-image-editor-imagick-test.php | 5 +++++ .../dominant-color-images/dominant-color-test.php | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php index 98a55ae863..ee4ae74303 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-image-editor-imagick-test.php @@ -24,6 +24,11 @@ public function test_get_dominant_color( $image_path, $expected_color, $expected $this->markTestSkipped( 'The Imagick PHP extension is not loaded.' ); } + $mime_type = wp_check_filetype( $image_path )['type']; + if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) { + $this->markTestSkipped( "Mime type $mime_type is not supported." ); + } + $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); wp_maybe_generate_attachment_metadata( get_post( $attachment_id ) ); diff --git a/tests/modules/images/dominant-color-images/dominant-color-test.php b/tests/modules/images/dominant-color-images/dominant-color-test.php index def232fef4..4ae090ccec 100644 --- a/tests/modules/images/dominant-color-images/dominant-color-test.php +++ b/tests/modules/images/dominant-color-images/dominant-color-test.php @@ -17,6 +17,11 @@ class Dominant_Color_Test extends DominantColorTestCase { * @covers ::dominant_color_metadata */ public function test_dominant_color_metadata( $image_path, $expected_color, $expected_transparency ) { + $mime_type = wp_check_filetype( $image_path )['type']; + if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) { + $this->markTestSkipped( "Mime type $mime_type is not supported." ); + } + // Non existing attachment. $dominant_color_metadata = dominant_color_metadata( array(), 1 ); $this->assertEmpty( $dominant_color_metadata ); @@ -38,6 +43,11 @@ public function test_dominant_color_metadata( $image_path, $expected_color, $exp * @covers ::dominant_color_get_dominant_color */ public function test_dominant_color_get_dominant_color( $image_path, $expected_color, $expected_transparency ) { + $mime_type = wp_check_filetype( $image_path )['type']; + if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) { + $this->markTestSkipped( "Mime type $mime_type is not supported." ); + } + // Creating attachment. $attachment_id = self::factory()->attachment->create_upload_object( $image_path ); $this->assertContains( dominant_color_get_dominant_color( $attachment_id ), $expected_color ); @@ -51,6 +61,11 @@ public function test_dominant_color_get_dominant_color( $image_path, $expected_c * @covers ::dominant_color_metadata */ public function test_has_transparency_metadata( $image_path, $expected_color, $expected_transparency ) { + $mime_type = wp_check_filetype( $image_path )['type']; + if ( ! wp_image_editor_supports( array( 'mime_type' => $mime_type ) ) ) { + $this->markTestSkipped( "Mime type $mime_type is not supported." ); + } + // Non-existing attachment. $transparency_metadata = dominant_color_metadata( array(), 1 ); $this->assertEmpty( $transparency_metadata ); From b664cae4feb2b4e629ec926a38a13b415c974510 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 24 Jan 2024 14:46:50 +0100 Subject: [PATCH 27/41] Use matrix for standalone plugin tests --- .github/workflows/php-test-standalone-plugins.yml | 13 +++++++++++++ bin/plugin/commands/test-plugins.js | 9 +++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/php-test-standalone-plugins.yml b/.github/workflows/php-test-standalone-plugins.yml index 3065f9f39a..3c52086a46 100644 --- a/.github/workflows/php-test-standalone-plugins.yml +++ b/.github/workflows/php-test-standalone-plugins.yml @@ -42,6 +42,19 @@ jobs: name: PHP Integration Tests for Standalone Plugins runs-on: ubuntu-latest timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + php: [ '8.2', '8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0' ] + wp: [ 'latest' ] + include: + - php: '7.4' + wp: '6.3' + - php: '8.3' + wp: 'trunk' + env: + WP_ENV_PHP_VERSION: ${{ matrix.php }} + WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} steps: - uses: styfle/cancel-workflow-action@0.11.0 - uses: actions/checkout@v3 diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 08a7b85a6b..bf44fc1dd8 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -320,13 +320,14 @@ function doRunUnitTests( settings ) { const isMultiSite = 'multi' === settings.siteType; let command = ''; + // wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test if ( isMultiSite ) { command = spawnSync( 'wp-env', [ 'run', - 'phpunit', - `'WP_MULTISITE=1 phpunit -c /var/www/html/wp-content/plugins/${ plugin }/multisite.xml --verbose --testdox'`, + 'tests-cli', + `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c tests/multisite.xml --verbose --testdox`, ], { shell: true, encoding: 'utf8' } ); @@ -335,8 +336,8 @@ function doRunUnitTests( settings ) { 'wp-env', [ 'run', - 'phpunit', - `'phpunit -c /var/www/html/wp-content/plugins/${ plugin }/phpunit.xml --verbose --testdox'`, + 'tests-cli', + `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit --verbose --testdox`, ], { shell: true, encoding: 'utf8' } ); From 9e7dc5b420dbfb938b4d463f06c75775a2c76f89 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 24 Jan 2024 14:53:22 +0100 Subject: [PATCH 28/41] Update configs --- bin/plugin/commands/test-plugins.js | 4 ++-- plugin-tests/.wp-env.json | 3 +-- plugin-tests/multisite.xml | 5 +++++ plugin-tests/phpunit.xml | 5 +++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index bf44fc1dd8..501dc2980b 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -327,7 +327,7 @@ function doRunUnitTests( settings ) { [ 'run', 'tests-cli', - `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c tests/multisite.xml --verbose --testdox`, + `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c plugin-tests/multisite.xml --verbose --testdox`, ], { shell: true, encoding: 'utf8' } ); @@ -337,7 +337,7 @@ function doRunUnitTests( settings ) { [ 'run', 'tests-cli', - `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit --verbose --testdox`, + `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c plugin-tests/phpunit.xml --verbose --testdox`, ], { shell: true, encoding: 'utf8' } ); diff --git a/plugin-tests/.wp-env.json b/plugin-tests/.wp-env.json index 9af20e97ab..673c3bd542 100644 --- a/plugin-tests/.wp-env.json +++ b/plugin-tests/.wp-env.json @@ -5,8 +5,7 @@ "tests": { "config": { "FS_METHOD": "direct" - }, - "phpVersion": "7.4" + } } } } diff --git a/plugin-tests/multisite.xml b/plugin-tests/multisite.xml index 0971a444be..59f52e39a6 100644 --- a/plugin-tests/multisite.xml +++ b/plugin-tests/multisite.xml @@ -14,4 +14,9 @@ ./tests + + + ms-excluded + + diff --git a/plugin-tests/phpunit.xml b/plugin-tests/phpunit.xml index 044c1447d2..d94c4a3d95 100644 --- a/plugin-tests/phpunit.xml +++ b/plugin-tests/phpunit.xml @@ -11,4 +11,9 @@ ./tests + + + ms-required + + From a3044dd62b40b6f5dc9dbf62c29f5a35ab0c422a Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 25 Jan 2024 10:38:11 +0530 Subject: [PATCH 29/41] Skip unsupported WebP tests --- tests/modules/images/webp-uploads/image-edit-tests.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/modules/images/webp-uploads/image-edit-tests.php b/tests/modules/images/webp-uploads/image-edit-tests.php index 3ba75f8008..64d47e7cff 100644 --- a/tests/modules/images/webp-uploads/image-edit-tests.php +++ b/tests/modules/images/webp-uploads/image-edit-tests.php @@ -473,6 +473,10 @@ public function it_should_prevent_to_store_an_empty_set_of_sources() { * @test */ public function it_should_store_the_next_image_hash_on_the_backup_sources() { + if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { + $this->markTestSkipped( 'Mime type image/webp is not supported.' ); + } + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leafs.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); // Edit the image. From 7449075425f281aa2b7fcb2bed0f0f8e4063ef17 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 25 Jan 2024 11:07:00 +0530 Subject: [PATCH 30/41] Fix test-plugins command --- bin/plugin/commands/test-plugins.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 501dc2980b..543f6ebf44 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -320,14 +320,13 @@ function doRunUnitTests( settings ) { const isMultiSite = 'multi' === settings.siteType; let command = ''; - // wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test if ( isMultiSite ) { command = spawnSync( 'wp-env', [ 'run', 'tests-cli', - `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c plugin-tests/multisite.xml --verbose --testdox`, + `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c multisite.xml --verbose --testdox`, ], { shell: true, encoding: 'utf8' } ); @@ -337,7 +336,7 @@ function doRunUnitTests( settings ) { [ 'run', 'tests-cli', - `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c plugin-tests/phpunit.xml --verbose --testdox`, + `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } vendor/bin/phpunit -c phpunit.xml --verbose --testdox`, ], { shell: true, encoding: 'utf8' } ); From 879647b493d9ec3ad0c67049666ec36733340bbd Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 25 Jan 2024 14:28:28 +0530 Subject: [PATCH 31/41] Add error log --- bin/plugin/commands/test-plugins.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 543f6ebf44..23876c9f2d 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -342,6 +342,10 @@ function doRunUnitTests( settings ) { ); } + if ( command.stderr ) { + log( formats.error( command.stderr.replace( '\n', '' ) ) ); + } + log( command.stdout.replace( '\n', '' ) ); if ( 1 === command.status ) { From 5bed5a952a61c07c2ec62b8120b47c807d9a70c6 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 25 Jan 2024 11:27:10 +0100 Subject: [PATCH 32/41] Composer update before running plugin tests --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 8599872cd7..b99cb7b404 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "readme": "./bin/plugin/cli.js readme", "translations": "./bin/plugin/cli.js translations", "build-plugins": "./bin/plugin/cli.js build-plugins", + "pretest-plugins": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction", "test-plugins": "./bin/plugin/cli.js test-plugins", + "pretest-plugins-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction", "test-plugins-multisite": "./bin/plugin/cli.js test-plugins --sitetype=multi", "enabled-modules": "./bin/plugin/cli.js enabled-modules", "format-js": "wp-scripts format", From 7d560aeb42b528eed8b1449174fc35d3e4cd795b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 25 Jan 2024 11:37:58 +0100 Subject: [PATCH 33/41] Move script to test-plugins.js --- bin/plugin/commands/test-plugins.js | 17 +++++++++++++++++ package.json | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 23876c9f2d..1702a3cc3f 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -507,6 +507,23 @@ function doRunStandalonePluginTests( settings ) { // Handle replacement of wp-env file content for round 1 of testing without root plugin. doReplaceWpEnvContent( { ...settings, builtPlugins } ); + // Update PHPUnit if necessary. + const command = spawnSync( + 'wp-env', + [ + 'run', + 'tests-cli', + `--env-cwd=/var/www/html/wp-content/plugins/${ settings.performancePluginSlug } composer update --no-interaction`, + ], + { shell: true, encoding: 'utf8' } + ); + + if ( command.stderr ) { + log( formats.error( command.stderr.replace( '\n', '' ) ) ); + } + + log( command.stdout.replace( '\n', '' ) ); + // Run unit tests with main WPP plugin disabled. const disablePlugins = [ settings.performancePluginSlug ]; diff --git a/package.json b/package.json index b99cb7b404..8599872cd7 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,7 @@ "readme": "./bin/plugin/cli.js readme", "translations": "./bin/plugin/cli.js translations", "build-plugins": "./bin/plugin/cli.js build-plugins", - "pretest-plugins": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction", "test-plugins": "./bin/plugin/cli.js test-plugins", - "pretest-plugins-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction", "test-plugins-multisite": "./bin/plugin/cli.js test-plugins --sitetype=multi", "enabled-modules": "./bin/plugin/cli.js enabled-modules", "format-js": "wp-scripts format", From 18dfefaf0c2fb9680c061fe264d069d187416e33 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 25 Jan 2024 11:48:41 +0100 Subject: [PATCH 34/41] Move step --- bin/plugin/commands/test-plugins.js | 46 +++++++++++------------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 1702a3cc3f..71238e20e0 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -472,7 +472,7 @@ function doRunStandalonePluginTests( settings ) { ); log( formats.success( - `Copied test assets for plugin "${ plugin }", executing "composer install --no-interaction" on plugin.\n` + `Copied test assets for plugin "${ plugin }", executing "composer update --no-interaction" on plugin.\n` ) ); } catch ( e ) { @@ -486,18 +486,23 @@ function doRunStandalonePluginTests( settings ) { process.exit( 1 ); } - // Execute composer install within built plugin following copy. - execSync( - `composer install --working-dir=${ settings.builtPluginsDir }${ plugin } --no-interaction`, - ( err, output ) => { - if ( err ) { - log( formats.error( `${ err }` ) ); - process.exit( 1 ); - } - // log the output received from the command - log( output ); - } + // Execute composer update within built plugin following copy. + // Ensures PHPUnit is downgraded/upgrades as necessary. + const command = spawnSync( + 'wp-env', + [ + 'run', + 'tests-cli', + `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } composer update --no-interaction`, + ], + { shell: true, encoding: 'utf8' } ); + + if ( command.stderr ) { + log( formats.error( command.stderr.replace( '\n', '' ) ) ); + } + + log( command.stdout.replace( '\n', '' ) ); } ); // Add the root level WPP plugin to the built plugins array. @@ -507,23 +512,6 @@ function doRunStandalonePluginTests( settings ) { // Handle replacement of wp-env file content for round 1 of testing without root plugin. doReplaceWpEnvContent( { ...settings, builtPlugins } ); - // Update PHPUnit if necessary. - const command = spawnSync( - 'wp-env', - [ - 'run', - 'tests-cli', - `--env-cwd=/var/www/html/wp-content/plugins/${ settings.performancePluginSlug } composer update --no-interaction`, - ], - { shell: true, encoding: 'utf8' } - ); - - if ( command.stderr ) { - log( formats.error( command.stderr.replace( '\n', '' ) ) ); - } - - log( command.stdout.replace( '\n', '' ) ); - // Run unit tests with main WPP plugin disabled. const disablePlugins = [ settings.performancePluginSlug ]; From 6324c63dc81967e292624c5b620d155837dc57b3 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 26 Jan 2024 10:24:12 +0530 Subject: [PATCH 35/41] Adjust step for composer update --- bin/plugin/commands/test-plugins.js | 48 ++++++++++++++++------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/bin/plugin/commands/test-plugins.js b/bin/plugin/commands/test-plugins.js index 71238e20e0..1394698a2c 100644 --- a/bin/plugin/commands/test-plugins.js +++ b/bin/plugin/commands/test-plugins.js @@ -316,6 +316,18 @@ function doRunUnitTests( settings ) { ) ); + execSync( + `composer install --working-dir=${ settings.builtPluginsDir }${ plugin } --no-interaction`, + ( err, output ) => { + if ( err ) { + log( formats.error( `${ err }` ) ); + process.exit( 1 ); + } + // log the output received from the command + log( output ); + } + ); + // Define multi site flag based on single vs multi sitetype arg. const isMultiSite = 'multi' === settings.siteType; let command = ''; @@ -342,13 +354,12 @@ function doRunUnitTests( settings ) { ); } - if ( command.stderr ) { - log( formats.error( command.stderr.replace( '\n', '' ) ) ); - } - log( command.stdout.replace( '\n', '' ) ); if ( 1 === command.status ) { + // Log error. + log( formats.error( command.stderr.replace( '\n', '' ) ) ); + log( formats.error( `One or more tests failed for plugin ${ plugin }` @@ -472,7 +483,7 @@ function doRunStandalonePluginTests( settings ) { ); log( formats.success( - `Copied test assets for plugin "${ plugin }", executing "composer update --no-interaction" on plugin.\n` + `Copied test assets for plugin "${ plugin }", executing "composer install --no-interaction" on plugin.\n` ) ); } catch ( e ) { @@ -486,23 +497,18 @@ function doRunStandalonePluginTests( settings ) { process.exit( 1 ); } - // Execute composer update within built plugin following copy. - // Ensures PHPUnit is downgraded/upgrades as necessary. - const command = spawnSync( - 'wp-env', - [ - 'run', - 'tests-cli', - `--env-cwd=/var/www/html/wp-content/plugins/${ plugin } composer update --no-interaction`, - ], - { shell: true, encoding: 'utf8' } + // Execute composer install within built plugin following copy. + execSync( + `composer install --working-dir=${ settings.builtPluginsDir }${ plugin } --no-interaction`, + ( err, output ) => { + if ( err ) { + log( formats.error( `${ err }` ) ); + process.exit( 1 ); + } + // log the output received from the command + log( output ); + } ); - - if ( command.stderr ) { - log( formats.error( command.stderr.replace( '\n', '' ) ) ); - } - - log( command.stdout.replace( '\n', '' ) ); } ); // Add the root level WPP plugin to the built plugins array. From 20155d53f91f7890a4ecf459c4b2bd70011ca89f Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 26 Jan 2024 12:35:14 +0530 Subject: [PATCH 36/41] Add missing php setup step in workflow --- .github/workflows/php-test-standalone-plugins.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/php-test-standalone-plugins.yml b/.github/workflows/php-test-standalone-plugins.yml index 3c52086a46..410ae38028 100644 --- a/.github/workflows/php-test-standalone-plugins.yml +++ b/.github/workflows/php-test-standalone-plugins.yml @@ -58,6 +58,9 @@ jobs: steps: - uses: styfle/cancel-workflow-action@0.11.0 - uses: actions/checkout@v3 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} - name: Setup Node.js (.nvmrc) uses: actions/setup-node@v3 with: @@ -65,6 +68,12 @@ jobs: cache: npm - name: npm install run: npm ci + - name: General debug information + run: | + npm --version + node --version + composer --version + php -v - name: Building standalone plugins run: npm run build-plugins - name: Running single site standalone plugin integration tests From 99f426203582c424503fd0e58eb6f270d3eb517d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 29 Jan 2024 17:15:25 +0100 Subject: [PATCH 37/41] Sanitize slashes for `Server-Timing` header --- server-timing/class-perflab-server-timing.php | 5 ++++- .../perflab-server-timing-tests.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/server-timing/class-perflab-server-timing.php b/server-timing/class-perflab-server-timing.php index 66f376ab2b..441d3a4c1c 100644 --- a/server-timing/class-perflab-server-timing.php +++ b/server-timing/class-perflab-server-timing.php @@ -95,7 +95,10 @@ public function register_metric( $metric_slug, array $args ) { return; } - $this->registered_metrics[ $metric_slug ] = new Perflab_Server_Timing_Metric( $metric_slug ); + // See https://github.com/WordPress/performance/issues/955 + $sanitized_slug = str_replace( '/', '-', $metric_slug ); + + $this->registered_metrics[ $metric_slug ] = new Perflab_Server_Timing_Metric( $sanitized_slug ); $this->registered_metrics_data[ $metric_slug ] = $args; // If the current user has already been determined and they lack the necessary access, diff --git a/tests/server-timing/perflab-server-timing-tests.php b/tests/server-timing/perflab-server-timing-tests.php index 33d7ca28be..1e5fc5a028 100644 --- a/tests/server-timing/perflab-server-timing-tests.php +++ b/tests/server-timing/perflab-server-timing-tests.php @@ -10,6 +10,9 @@ */ class Perflab_Server_Timing_Tests extends WP_UnitTestCase { + /** + * @var Perflab_Server_Timing + */ private $server_timing; private static $admin_id; @@ -119,6 +122,19 @@ public function test_has_registered_metric() { $this->assertTrue( $this->server_timing->has_registered_metric( 'metric-to-check-for' ), 'Metric should be available after registration' ); } + public function test_register_metric_replaces_slashes() { + $this->server_timing->register_metric( + 'foo/bar/baz', + array( + 'measure_callback' => static function ( $metric ) { + $metric->set_value( 123 ); + }, + 'access_cap' => 'exist', + ) + ); + $this->assertSame( 'wp-foo-bar-baz;dur=123', $this->server_timing->get_header() ); + } + /** * @dataProvider data_get_header */ From 1819c2b34f803dd473a2591a88815012e0111723 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 29 Jan 2024 17:17:58 +0100 Subject: [PATCH 38/41] Lint fix --- server-timing/class-perflab-server-timing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-timing/class-perflab-server-timing.php b/server-timing/class-perflab-server-timing.php index 441d3a4c1c..68d704564f 100644 --- a/server-timing/class-perflab-server-timing.php +++ b/server-timing/class-perflab-server-timing.php @@ -95,7 +95,7 @@ public function register_metric( $metric_slug, array $args ) { return; } - // See https://github.com/WordPress/performance/issues/955 + // See https://github.com/WordPress/performance/issues/955. $sanitized_slug = str_replace( '/', '-', $metric_slug ); $this->registered_metrics[ $metric_slug ] = new Perflab_Server_Timing_Metric( $sanitized_slug ); From 00efe96781dec1cec9c101a3848ec64bbace21dc Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 29 Jan 2024 17:35:46 +0100 Subject: [PATCH 39/41] Move to `format_metric_header_value` actually --- server-timing/class-perflab-server-timing.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server-timing/class-perflab-server-timing.php b/server-timing/class-perflab-server-timing.php index 68d704564f..f0c9751fe5 100644 --- a/server-timing/class-perflab-server-timing.php +++ b/server-timing/class-perflab-server-timing.php @@ -95,10 +95,7 @@ public function register_metric( $metric_slug, array $args ) { return; } - // See https://github.com/WordPress/performance/issues/955. - $sanitized_slug = str_replace( '/', '-', $metric_slug ); - - $this->registered_metrics[ $metric_slug ] = new Perflab_Server_Timing_Metric( $sanitized_slug ); + $this->registered_metrics[ $metric_slug ] = new Perflab_Server_Timing_Metric( $metric_slug ); $this->registered_metrics_data[ $metric_slug ] = $args; // If the current user has already been determined and they lack the necessary access, @@ -261,6 +258,10 @@ private function format_metric_header_value( Perflab_Server_Timing_Metric $metri if ( is_float( $value ) ) { $value = round( $value, 2 ); } - return sprintf( 'wp-%1$s;dur=%2$s', $metric->get_slug(), $value ); + + // See https://github.com/WordPress/performance/issues/955. + $name = str_replace( '/', '-', $metric->get_slug() ); + + return sprintf( 'wp-%1$s;dur=%2$s', $name, $value ); } } From cd7a7460d4f3ff73f14d31175b73d51d368cc829 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 29 Jan 2024 10:04:16 -0800 Subject: [PATCH 40/41] Add standalone plugin version constants for auto-sizes and speculation-rules --- load.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/load.php b/load.php index ce20b2e267..23f8503463 100644 --- a/load.php +++ b/load.php @@ -337,6 +337,8 @@ function perflab_get_standalone_plugin_version_constants( $source = 'plugins' ) 'webp-uploads' => 'WEBP_UPLOADS_VERSION', 'dominant-color-images' => 'DOMINANT_COLOR_IMAGES_VERSION', 'performant-translations' => 'PERFORMANT_TRANSLATIONS_VERSION', + 'auto-sizes' => 'IMAGE_AUTO_SIZES_VERSION', + 'speculation-rules' => 'SPECULATION_RULES_VERSION', ); } From f1aac489d29db0b6ce13488db13d3c812ba3eee5 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 29 Jan 2024 20:13:51 +0100 Subject: [PATCH 41/41] Update server-timing/class-perflab-server-timing.php Co-authored-by: Weston Ruter --- server-timing/class-perflab-server-timing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-timing/class-perflab-server-timing.php b/server-timing/class-perflab-server-timing.php index f0c9751fe5..bf9fae647e 100644 --- a/server-timing/class-perflab-server-timing.php +++ b/server-timing/class-perflab-server-timing.php @@ -260,7 +260,7 @@ private function format_metric_header_value( Perflab_Server_Timing_Metric $metri } // See https://github.com/WordPress/performance/issues/955. - $name = str_replace( '/', '-', $metric->get_slug() ); + $name = preg_replace( '/[^!#$%&\'*+\-.^_`|~0-9a-zA-Z]/', '-', $metric->get_slug() ); return sprintf( 'wp-%1$s;dur=%2$s', $name, $value ); }