-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.7][BC Break][Translation] Undocumented BC break regarding caching #14689
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
Comments
ping @aitboudad |
I didn't introduced anythink I tried to just to improve #13074, we can just use count to solve the serialize issue. $catalogueHash = sha1(serialize(array(
'resources' => isset($this->resources[$locale]) ? count($this->resources[$locale]) : 0,
'fallback_locales' => $this->fallbackLocales,
))); |
Seems like a good fix to me 👍 |
@iltar Resources are already serialized in other places (in the .meta file of the ConfigCache for instance). so 2.6 was probably already serializing them, but in a different place. |
@stof I don't know about that, but this is since 2.7 as you can see in the changes in the file. In 2.6 this works just fine but in 2.7 and 2.8 it's broken. I don't think the resource was serialized the same way as now in 8000 that case or I'm using a different strategy without knowing it. |
fixed by #14705 |
@stof Sure we're talking about the same kind of resource here? |
The problem that we tried to solve was that the Translator needs to use a different cache file when it is configured differently (think of resources added or removed or configured differently). Just using the number of resources added will not suffice to cover all the (edge?) cases. I don't think the resources themselves have to be serializable (they are not necessariliy those put into the |
…tboudad) This PR was merged into the 2.7 branch. Discussion ---------- [Translator] avoid serialize unserializable resources. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | #14689 | Tests pass? | yes | License | MIT Commits ------- 7220f2c [Translator] avoid serialize unserializable resources.
I'm using a custom translation loader where the loader is the resource, a database loader like this one. The problem is that as of symfony 2.7, the creating of the cache is slightly changed, it also serializes the resource now. Because my resource is using an entity manager to fetch the translations, it tries to serialize the EM and this of course fails.
A solution is to implement the
Serializable
interface or to use thespl_object_hash()
instead.https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/Translation/Translator.php#L376-L379
https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Translation/Translator.php#L420-L428
The text was updated successfully, but these errors were encountered: