ZF-8448: Translate_Adapter throws warning if $messageId is object

Issue Type: Bug Created: 2009-12-02T14:24:10.000+0000 Last Updated: 2010-01-18T05:44:09.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Michal Vrchota (techi) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments:


Sometimes object is passed to the $messageId (i.e. via Zend_Form instance of class with toString() magic method is passed as value) however that $messageId is not translated and gives

PHP Warning: Illegal offset type in isset or empty in /home/www/app/library/Zend/Translate/Adapter.php on line 682

This should fix the problem if (is_object($messageId)) $messageId = (string)$messageId;


Posted by Thomas Weidner (thomas) on 2009-12-02T14:49:29.000+0000

Zend_Translate MUST have an string as key. Other types are not allowed and should not be given.

Using toString implicitly by isTranslated() would add problems. In my opinion it's better to have this warning to force the user to prevent those problems.

Posted by Michal Vrchota (techi) on 2009-12-02T18:27:19.000+0000

The thing is, that it is very difficult to track down the source code - where the object was passed. So I suggest to throw an exception instead.

IMHO 1 exception (which can be easily tracked) is better then thousands of pointless warnings in php error log

Posted by Thomas Weidner (thomas) on 2009-12-03T03:22:07.000+0000

I agree on the notice being suppressed. But I do not agree on throwing an exception while translating.

Calling "translate()" it is NOT ALLOWED to throw an exception in any case. The return value must be equal with the input when no translation can be done.

Posted by Thomas Weidner (thomas) on 2009-12-03T03:58:17.000+0000

Notices are no longer given with r19367. Exceptions will not be integrated for translation.

Posted by Renat Ismagilov (rismagi) on 2010-01-18T04:56:39.000+0000

Translate_Adapter still throws warnings by isTranslated method:

    if (isset($this->_translate[$locale][$messageId]) === true) {
        // return original translation
        return true;

should be fixed also.

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.