8000 bug #60137 [Config] ResourceCheckerConfigCache metadata unserialize e… · symfony/symfony@e10963f · GitHub
[go: up one dir, main page]

Skip to content

Commit e10963f

Browse files
committed
bug #60137 [Config] ResourceCheckerConfigCache metadata unserialize emits warning (Colin Michoudet)
This PR was merged into the 7.2 branch. Discussion ---------- [Config] ResourceCheckerConfigCache metadata unserialize emits warning | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #59196 | License | MIT ## Description This PR fixes the warning unserialize(): Function spl_autoload_call() hasn't defined the class it was called for that occurs when unserializing metadata in the ResourceCheckerConfigCache when unserialize_callback_func is set to spl_autoload_call. The fix adds the allowed_classes => false parameter to the unserialize() call, preventing PHP from attempting to reconstruct objects of unknown classes, which eliminates the warnings while maintaining the intended functionality. ## Test case The issue can be reproduced by: 1. Adding `ini_set('unserialize_callback_func', 'spl_autoload_call');` at the beginning of a Symfony application (e.g., in `bin/console`) 2. Running `bin/console cache:clear` 3. Observing the warnings about classes that couldn't be found With this change, the warnings no longer appear while the cache continues to function correctly. Commits ------- e50f936 bug #59196 [Config] ResourceCheckerConfigCache metadata unserialize emits warning
2 parents 790a0c8 + e50f936 commit e10963f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Config/ResourceCheckerConfigCache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function write(string $content, ?array $metadata = null): void
127127

128128
$ser = preg_replace_callback('/;O:(\d+):"/', static fn ($m) => ';O:'.(9 + $m[1]).':"Tracking\\', $ser);
129129
$ser = preg_replace_callback('/s:(\d+):"\0[^\0]++\0/', static fn ($m) => 's:'.($m[1] - \strlen($m[0]) + 6).':"', $ser);
130-
$ser = unserialize($ser);
130+
$ser = unserialize($ser, ['allowed_classes' => false]);
131131
$ser = @json_encode($ser, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) ?: [];
132132
$ser = str_replace('"__PHP_Incomplete_Class_Name":"Tracking\\\\', '"@type":"', $ser);
133133
$ser = \sprintf('{"resources":%s}', $ser);

0 commit comments

Comments
 (0)
0