From de535c2512e5affe3d5130e63e04385468ce78b7 Mon Sep 17 00:00:00 2001 From: Peter Downey Date: Tue, 24 Nov 2026 01:40:05 -0500 Subject: [PATCH 1/3] Refuse unserializing the coordinator from __unserialize() PHP 8.5 deprecates __wakeup(), and Psalm 7.16 reports declaring it as DeprecatedSyntax. PHP calls __unserialize() for every unserialize() of the class, so the singleton is still refused with the same escaped LogicException. One test now goes through a real unserialize() call. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + includes/class-optimizations-ace-mc.php | 8 +++++++- languages/optimizations-ace-mc.pot | 4 ++-- tests/unit/PluginWiringTest.php | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ffb155..26ee880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The translation template is now generated locally with `composer make-pot` and committed with each change; the Update Translation File workflow was removed - The translation template names the GitHub issue tracker as its bug report address, in place of a WordPress.org support forum the plugin does not have, and its source references were refreshed - The code uses PHP 8 forms: short arrays, constructor property promotion, `readonly` classes and properties for the optimization and admin classes, and a null-coalescing assignment. Behavior is unchanged +- The plugin coordinator refuses to be unserialized from `__unserialize()` in place of `__wakeup()`, which PHP 8.5 deprecates. Behavior is unchanged - A new Rector job fails when PHP 8.3 or Rector's dead-code, code-quality, type-declaration, or early-return rules would change the code; `rector.php` skips the rules that conflict with WordPress, each with its reason. PHPCS requires the short array syntax - ESLint applies modern-JavaScript rules, and ESLint and Stylelint fail on a browser feature that WordPress's supported browsers lack. `package.json` overrides `smol-toml`, `katex`, and `re2js` (used by the Markdown linter) for their advisories diff --git a/includes/class-optimizations-ace-mc.php b/includes/class-optimizations-ace-mc.php index 7dee0f4..7c7a2ce 100644 --- a/includes/class-optimizations-ace-mc.php +++ b/includes/class-optimizations-ace-mc.php @@ -63,10 +63,16 @@ private function __clone() {} /** * Prevent unserializing. * + * PHP calls __unserialize() for every unserialize() of this class; it + * replaces __wakeup(), which PHP 8.5 deprecates. + * * @since 1.0.7 + * @param array $data The serialized properties, never used. * @throws LogicException Always; the coordinator must not be recreated from serialized data. */ - public function __wakeup(): void { + public function __unserialize( array $data ): void { + unset( $data ); + throw new LogicException( esc_html__( 'Unserializing is not allowed.', 'optimizations-ace-mc' ) ); } diff --git a/languages/optimizations-ace-mc.pot b/languages/optimizations-ace-mc.pot index 94a0893..7c7b143 100644 --- a/languages/optimizations-ace-mc.pot +++ b/languages/optimizations-ace-mc.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2026-11-14T08:51:05+00:00\n" +"POT-Creation-Date: 2026-11-24T06:38:55+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.12.0\n" "X-Domain: optimizations-ace-mc\n" @@ -164,6 +164,6 @@ msgstr "" msgid "Certifications:" msgstr "" -#: includes/class-optimizations-ace-mc.php:70 +#: includes/class-optimizations-ace-mc.php:76 msgid "Unserializing is not allowed." msgstr "" diff --git a/tests/unit/PluginWiringTest.php b/tests/unit/PluginWiringTest.php index 7e99842..e6f2a28 100644 --- a/tests/unit/PluginWiringTest.php +++ b/tests/unit/PluginWiringTest.php @@ -110,7 +110,7 @@ public function test_a_second_coordinator_cannot_be_made(): void { $this->assertTrue( $class->isFinal() ); $this->expectException( LogicException::class ); - Optimizations_Ace_Mc::instance()->__wakeup(); + unserialize( sprintf( 'O:%d:"%s":0:{}', strlen( Optimizations_Ace_Mc::class ), Optimizations_Ace_Mc::class ) ); } /** @@ -120,7 +120,7 @@ public function test_unserialize_refusal_message_is_escaped(): void { $this->use_translation_with_markup(); try { - Optimizations_Ace_Mc::instance()->__wakeup(); + Optimizations_Ace_Mc::instance()->__unserialize( [] ); $this->fail( 'Unserializing must be refused.' ); } catch ( LogicException $exception ) { $this->assert_no_raw_markup( $exception->getMessage() ); From 6eeff1018a68d29b4276807828a6b9112fc6daad Mon Sep 17 00:00:00 2001 From: Peter Downey Date: Tue, 24 Nov 2026 01:43:53 -0500 Subject: [PATCH 2/3] Call __unserialize() directly in the coordinator test Codacy's Semgrep rule flags any unserialize() call, test code included. The test calls the magic method the way it called __wakeup() before. Co-Authored-By: Claude Opus 5.5 --- tests/unit/PluginWiringTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/PluginWiringTest.php b/tests/unit/PluginWiringTest.php index e6f2a28..37002ef 100644 --- a/tests/unit/PluginWiringTest.php +++ b/tests/unit/PluginWiringTest.php @@ -110,7 +110,7 @@ public function test_a_second_coordinator_cannot_be_made(): void { $this->assertTrue( $class->isFinal() ); $this->expectException( LogicException::class ); - unserialize( sprintf( 'O:%d:"%s":0:{}', strlen( Optimizations_Ace_Mc::class ), Optimizations_Ace_Mc::class ) ); + Optimizations_Ace_Mc::instance()->__unserialize( [] ); } /** From b44a175f0b6aae9a10b90275a7a6304fa680e302 Mon Sep 17 00:00:00 2001 From: Peter Downey Date: Tue, 24 Nov 2026 02:04:35 -0500 Subject: [PATCH 3/3] Require ext-filter for Psalm 7.17 Psalm 7.17 reports MissingExtensionRequirement for filter_var() when composer.json does not require ext-filter. The code needs the extension, so composer.json now requires it; the lock hash is refreshed. Co-Authored-By: Claude Opus 5.5 --- composer.json | 3 ++- composer.lock | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index f11adb7..8fcc08a 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ ], "minimum-stability": "stable", "require": { - "php": ">=8.3" + "php": ">=8.3", + "ext-filter": "*" }, "require-dev": { "phpunit/phpunit": "^11.5 || ^12.5 || ^13.4", diff --git a/composer.lock b/composer.lock index a888bce..a0ace75 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": "5b8703d15507c720ba0b4f4d28ff1ccc", + "content-hash": "ce72259d2c2957f9a02b872aba4214b4", "packages": [], "packages-dev": [ { @@ -8335,7 +8335,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=8.3" + "php": ">=8.3", + "ext-filter": "*" }, "platform-dev": {}, "platform-overrides": {