ZF-2904: Zend_Translate_Adapter ignores parameters when cache is used

Issue Type: Bug Created: 2008-03-17T15:16:36.000+0000 Last Updated: 2008-09-02T10:39:13.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Christoph Schulte Mönting (csm) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments:


German text 1English text 1


Posted by Thomas Weidner (thomas) on 2008-03-17T16:09:49.000+0000

As stated in the manual you MUST set the cache BEFORE creating the object. See…

Using the same cache for different objects like in your case makes of course problems not only in this component... it leads to unexpectable behaviour as you do not know what's written and what's left from the first object.

Posted by Christoph Schulte Mönting (csm) on 2008-03-18T03:10:55.000+0000

But that is what my example code does: It creates and sets the cache, and then (by calling testTranslate()) twice creates a translate object and uses it. If you want, you can rewrite it to

<pre class="highlight">
$translationCache = Zend_Cache::factory('Page', 'File');

$translate1 = new Zend_Translate('tmx', 'texts.tmx', 'de');

Zend_Debug::dump($translate1->getLocale(), 'Locale');
Zend_Debug::dump($translate1->getMessages(), 'Messages');

$translate2 = new Zend_Translate('tmx', 'texts.tmx', 'de');

Zend_Debug::dump($translate2->getLocale(), 'Locale');
Zend_Debug::dump($translate2->getMessages(), 'Messages');

which clearly is what the documentation says and does not work either. The point is not that the example creates two instances at the same time, the point is that writing and restoring from and to the cache will lead to parameters being ignored. Please have a look at Zend_Translate_Adapter's constructor, it is obviously not correct.

Posted by Thomas Weidner (thomas) on 2008-03-24T08:35:34.000+0000

2 things to mention:

*) You must not use the incubator in such situations *) You can try r9038 or higher where the options have been added to cache

But it has to be mentioned that using caches in the way you show it, is problematic. It is not allowed to have 2 identical adapters with different options. This is against generic rules and leads to the problem that the user has to be aware of which class holds which translation. This is not allowed and also not supported.

With the actual revision there is no problem within your testcode.

Posted by Wil Sinclair (wil) on 2008-09-02T10:39:13.000+0000

Updating for the 1.6.0 release.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.