Home » Internationalization » Translation2 » Bug #3408
XML container : empty data sets badly handled
Details
| Submitted | 2005-02-08 17:12 UTC |
|---|---|
| From | ylf at xung dot org |
| Assigned | quipo |
| Status | Closed |
| Package | Translation2 |
| PHP Version | 4.3.4 |
| OS | Linux Debian |
| Roadmaps | (Not assigned) |
Comments
[2005-02-08 17:12 UTC] ylf at xung dot org
Description:
------------
Hi,
Here's the symptom, for both the current cvs and 2.0.0beta6 :
Warning: array_pop(): The argument should be an array in /var/www/dev/pear_cvs/Translation2/Container/xml.php on line 280
Warning: Invalid argument supplied for foreach() in /var/www/dev/pear_cvs/Translation2/Container/xml.php on line 196
This happens with an empty page, ie :
<page name="myPage">
</page>
The problem comes from XML_Unserializer which sets $this->_data['pages']['myPage'] to an empty string when it should be an empty array.
Similar issues are likely to happen for any of the tags that have an undefined (possibly null) number of sub-tags, as defined in the DTD :
<!ELEMENT languages (lang*)>
<!ELEMENT pages (page*)>
<!ELEMENT page (string*)>
<!ELEMENT string (tr*)>
I believe the DTD is just fine, and that it is a good thing to allow empty pages, empty strings, etc... So that the developer can produce a draft of all needed strings and pages before the translator fills them in.
Here's a fix for the XML container and scripts/t2xmlchk.php, which applies fine against the current cvs version :
http://samalyse.com/ln/0011.php
Cheers