Skip to content
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

Using a Filesystem cache storage adapter results in an exception #10

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment · May be fixed by #123
Open

Using a Filesystem cache storage adapter results in an exception #10

weierophinney opened this issue Dec 31, 2019 · 1 comment · May be fixed by #123
Assignees

Comments

@weierophinney
Copy link
Member

Object of class Zend\I18n\Translator\TextDomain could not be converted to string

Switching to another adapter (like memory) works fine, looks like this happens because Filesystem doesn’t do any serialization, just:

// Zend\Cache\Storage\Adapter\Filesystem::putFileContent()
if (! is_string($data)) {
    // Ensure we have a string
    $data = (string) $data;
}

I’m not sure if Translator should serialize the TextDomain object before storing it, or if this is more a bug in the cache adapter. Perhaps we should check whether the cache can indeed store objects by using $cache->getCapabilities(), and serialize it if not?


Originally posted by @kinglozzer at zendframework/zend-i18n#44

@weierophinney
Copy link
Member Author

@kinglozzer

the following works for me:

try installing zend-serializer and this configuration (i use a global config file for i18n in order to have language files inside a /path/to/app/lang dir, you can use a per-module config with getcwd() call replaced by __DIR__)

return [
//...
    'translator' => [
        //..
        'cache' => [
            'adapter' => [
                'name' => 'filesystem',
                'options' => [
                    'cache_dir' => getcwd() . '/data/cache',
                    'ttl'       => 3600,
                ],
            ],
            'plugins' => [
                'serializer',
                'exception_handler' => [
                    'throw_exceptions' => false,
                ],
            ],
        ],
    ];

kind regards,
maks


Originally posted by @pine3ree at zendframework/zend-i18n#44 (comment)

froschdesign added a commit to froschdesign/laminas-i18n that referenced this issue May 18, 2024
Fixes laminas#10

Signed-off-by: Frank Brückner <dev@froschdesignstudio.de>
@froschdesign froschdesign linked a pull request May 18, 2024 that will close this issue
froschdesign added a commit to froschdesign/laminas-i18n that referenced this issue May 18, 2024
Fixes laminas#10

Signed-off-by: Frank Brückner <dev@froschdesignstudio.de>
@froschdesign froschdesign self-assigned this May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants