Skip to content

[2.7][BC Break][Translation] Undocumented BC break regarding caching #14689

Closed
@linaori

Description

@linaori

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 the spl_object_hash() instead.

https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/Translation/Translator.php#L376-L379

    // 2.6
    private function getCatalogueCachePath($locale)
    {
        return $this->cacheDir.'/catalogue.'.$locale.'.'.sha1(serialize($this->fallbackLocales)).'.php';
    }

https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Translation/Translator.php#L420-L428

    // 2.7
    private function getCatalogueCachePath($locale)
    {
        $catalogueHash = sha1(serialize(array(
            'resources' => isset($this->resources[$locale]) ? $this->resources[$locale] : array(),
            'fallback_locales' => $this->fallbackLocales,
        )));
        return $this->cacheDir.'/catalogue.'.$locale.'.'.$catalogueHash.'.php';
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions