ZF-12012: Make the TMX parser output the filename when throwing an exception

Issue Type: Patch Created: 2012-01-19T17:20:00.000+0000 Last Updated: 2012-02-26T04:07:42.000+0000 Status: Resolved Fix version(s): - 1.11.12 (22/Jun/12)

Reporter: Florian Sesser (hacklschorsch) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Translate

Related issues: Attachments:


When parsing of an TMX file fails, an exception is thrown that reports the error and the line of the TMX file that was processed, but not the name of the TMX file. Instead, the (pretty useless) name of the TMX parser given.

This patch adds the filename to the error message, so one does know from the error message which TMX file could not be parsed (and then take a look at the TMX file).

Error-message before patch:

[exec] Zend_Translate_Exception: XML error: Not well-formed (invalid token) at line 1 in library/Zend/Translate/Adapter/Tmx.php on line 82

after patch:

[exec] Zend_Translate_Exception: XML error: Not well-formed (invalid token) at line 1 of file application/tmx/svn-commit.tmp in library/Zend/Translate/Adapter/Tmx.php on line 83

Please review the attached patch.


Posted by Florian Sesser (hacklschorsch) on 2012-01-19T17:22:30.000+0000

Huh, now how to add a patch here. I'll just post it as comment.

Index: library/Zend/Translate/Adapter/Tmx.php

--- library/Zend/Translate/Adapter/Tmx.php (revision 3015) +++ library/Zend/Translate/Adapter/Tmx.php (working copy) @@ -74,9 +74,10 @@ xml_set_character_data_handler($this->_file, "_contentElement");

     if (!xml_parse($this->_file, file_get_contents($filename))) {
  • $ex = sprintf('XML error: %s at line %d', + $ex = sprintf('XML error: %s at line %d of file %s', xml_error_string(xml_get_error_code($this->_file)), - xml_get_current_line_number($this->_file)); + xml_get_current_line_number($this->_file), + $filename); xml_parser_free($this->_file); require_once 'Zend/Translate/Exception.php'; throw new Zend_Translate_Exception($ex);

Posted by Florian Sesser (hacklschorsch) on 2012-01-19T17:27:48.000+0000

Now that worked really well. According to the Internets, I should have some "upload file" capability here. Probably it's disabled because you don't want to host random stuff?

Whatever, here's a link to the patch:

Posted by Adam Lundrigan (adamlundrigan) on 2012-02-26T04:07:11.000+0000

Fixed in trunk r24649 Merged to release-1.11 in r24650 ZF2 PR:

Have you found an issue?

See the Overview section for more details.


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

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