Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Config] ResourceCheckerConfigCache metadata unserialize emits warning #59196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simitter opened this issue Dec 12, 2024 · 5 comments
Closed

Comments

@simitter
Copy link

Symfony version(s) affected

7.2.1

Description

The ResourceCheckerConfigCache may crash while in dev environement /debug mode on unserialize.

In ResourceCheckerConfigCache.php line 130:
Warning: unserialize(): Function spl_autoload_call() hasn't defined the class it was called for

This happens if there is an additional unserialize_callback_func set

ini_set('unserialize_callback_func', 'spl_autoload_call');

How to reproduce

https://github.com/simitter/symfony_config_unserialize_bug

Steps:
On an empty cache bin/console should trigger the bug

Possible Solution

Using the allowed_classes parameter of unserialize should force every class to be __Php_Incomoplete_Class before triggering unserialize_callback_func.

Only suppressing the error on unseralize would prevent the metadata json file to be written / contain the correct data.

Additional Context

No response

@thePanz
Copy link
Contributor

thePanz commented Feb 7, 2025

Having the same issue as @simitter in a Symfony application which wraps a legacy Symfony1 application.

@oojacoboo
Copy link

I can confirm the same issue on 7.2.x, also wrapping a legacy sf1 application. The issue doesn't exist in 7.1.11.

@thePanz
Copy link
Contributor

thePanz commented Mar 4, 2025

I can confirm the same issue on 7.2.x, also wrapping a legacy sf1 application. The issue doesn't exist in 7.1.11.

@oojacoboo do you also notice that the Symfony debug-toolbar is not visible anymore when wrapping SF 1.x with SF 6.4 (while it was working with SF 5.4)? I guess there are some changes in the spl_autoload_call usage from newer SF 7.x versions, which breaks the older code

@oojacoboo
Copy link

@thePanz we haven't used that thing in a decade. Our sf1 implementation is really stripped down - basically just the controllers and views, nothing else.

@elcmichou
Copy link

Also experiencing the issue as @thePanz, with a Symfony application which wraps a legacy Symfony1 application.
Passing option allowed_classes: false seems to solve the issue.

elcmichou pushed a commit to elcmichou/symfony that referenced this issue Apr 3, 2025
fabpot added a commit that referenced this issue Apr 4, 2025
…mits 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
@fabpot fabpot closed this as completed Apr 4, 2025
alexandre-daubois added a commit that referenced this issue Apr 4, 2025
* 7.2:
  Update validators.pt.xlf
  bug #59196 [Config] ResourceCheckerConfigCache metadata unserialize emits warning
  fix(validator): only check for puny code in tld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants