From 615d496eba5140af05b81ec0d2bed1848b88cda0 Mon Sep 17 00:00:00 2001 From: "homeboy-ci[bot]" <266378653+homeboy-ci[bot]@users.noreply.github.com> Date: Mon, 26 Oct 2026 06:29:17 +0000 Subject: [PATCH] fix: resolve PHP 8.2 permission cache and font-dependent PHPUnit failures Closes #3683. Co-Authored-By: Extra Chill Bot (AI) --- inc/Core/FilesRepository/FilesystemHelper.php | 9 +++- .../Abilities/Media/StackTemplateTest.php | 5 ++ tests/filesystem-permission-cache-smoke.php | 48 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/filesystem-permission-cache-smoke.php diff --git a/inc/Core/FilesRepository/FilesystemHelper.php b/inc/Core/FilesRepository/FilesystemHelper.php index 5764b7ce6e..d9532e0576 100644 --- a/inc/Core/FilesRepository/FilesystemHelper.php +++ b/inc/Core/FilesRepository/FilesystemHelper.php @@ -106,6 +106,10 @@ public static function get(): ?\WP_Filesystem_Base { * @return bool True if the file is (or was made) group-writable, false otherwise. */ public static function make_group_writable( string $filepath, int $permissions = self::AGENT_FILE_PERMISSIONS ): bool { + // Atomic replacement or another process may have changed the inode or mode. + // Permission and ownership decisions must describe the current file. + clearstatcache( true, $filepath ); + if ( ! file_exists( $filepath ) ) { return false; } @@ -127,7 +131,10 @@ public static function make_group_writable( string $filepath, int $permissions = // Suppress any residual warning — a failed chmod is non-fatal here. // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_chmod, WordPress.PHP.NoSilencedErrors.Discouraged - return @chmod( $filepath, $permissions ); + $result = @chmod( $filepath, $permissions ); + // PHP 8.2 can retain the pre-chmod mode for subsequent stat calls. + clearstatcache( true, $filepath ); + return $result; } /** diff --git a/tests/Unit/Abilities/Media/StackTemplateTest.php b/tests/Unit/Abilities/Media/StackTemplateTest.php index 20fd9e35e9..7c853459e2 100644 --- a/tests/Unit/Abilities/Media/StackTemplateTest.php +++ b/tests/Unit/Abilities/Media/StackTemplateTest.php @@ -178,6 +178,11 @@ public function test_list_item_colors_render_without_leaking_to_other_items(): v ); $paths = \DataMachine\Abilities\Media\BrandTokens::with_overrides( $data['brand'], static fn() => $t->render( $data, $r ) ); $this->files = array_merge( $this->files, $paths ); + foreach ( array( 'body', 'heading' ) as $font ) { + if ( ! is_readable( $r->get_font( $font ) ) ) { + $this->markTestSkipped( 'Readable body and heading fonts required for pixel assertions.' ); + } + } $box = $t->plan_layout( $r, $data )[0]; $line = (int) ( 64 * 1.2 ); foreach ( array( 0 => 0xffffff, 1 => 0xff0000, 2 => 0xffffff ) as $i => $expected ) { diff --git a/tests/filesystem-permission-cache-smoke.php b/tests/filesystem-permission-cache-smoke.php new file mode 100644 index 0000000000..d2c8966a60 --- /dev/null +++ b/tests/filesystem-permission-cache-smoke.php @@ -0,0 +1,48 @@ +