ZF-11064: logUntranslated cause always write to cache
Description
When setting the config option "logUntranslated" to true, all untranslated are writte to the specified logger like expected.
BUT in Zend_Translate_Adapter, method setOptions (line 331): in the foreach the variable $change is set always true, so a write to the cache is performed.
See attachments for more information (profiler and patch)
Comments
Posted by Thomas Weidner (thomas) on 2011-02-16T12:51:34.000+0000
The method setOptions() is called only once... by the constructor of the translation adapter. See line 177.
When the method is called multiple times within your environment it would mean that you are creating multiple adapters by calling the constructor multiple times.
The second thing to mention is that the cache is only written when a option has been changed and this option is not 'locale'. See the lines 340 and 342.
Posted by Thomas Weidner (thomas) on 2011-02-19T10:43:12.000+0000
Closing as non-reproduceable Feel free to reopen when you have new informations which allow reproduction of the problem
Posted by Martin Keckeis (thadafinser) on 2011-02-21T01:16:30.000+0000
The responsible key is "log" not locale, that the variable $change is set always to true (see my attached patch).
The __construct() is only called only one time.
This seems to be the problem: The option "logUntranslated" is set to true in my options and in this profiler screenshots is a untranslated string. So the log writer will write the untranslated string to the logfile (which is a change...), but for the cache nothing has really changed (but it gets written new for nothing).
Posted by Thomas Weidner (thomas) on 2011-02-22T11:42:03.000+0000
The problem is not that __construct() is called only once. Calling it multiple times would mean to create multiple instances of Zend_Translate.
Also your pictures do not show that the cache is written multiple times. It is only written once after __construct() has been called.
With actual informations I can not reproduce that the cache is written every time when an untranslated string has been added to the log.
Posted by Martin Keckeis (thadafinser) on 2011-02-23T01:30:39.000+0000
It seems we missunderstood each other.
The cache is not written multiple times, it's only writte once per request.
BUT
the write to the cache is not necessary, because the translation content itself has not changed! Why should the cache get written, only because a log entry is written somewhere else?
Posted by Thomas Weidner (thomas) on 2011-08-26T18:21:14.000+0000
Fixed in ZF2 with GH-298