Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.4

Bug #12183 Default language ID '0' considered to be invalid
Submitted: 2007-10-04 09:13 UTC
From: clue Assigned: quipo
Status: Closed Package: Translation2 (version 2.0.0RC1)
PHP Version: 5.2.3 OS: Debian Lenny GNU/Linux
Roadmaps: (Not assigned)    
Subscription  


 [2007-10-04 09:13 UTC] clue (Christian Lück)
Description: ------------ When creating a new language and not specifying a language ID it'll assume a numeric default ID starting from 0 onwards. This ID however is considered invalid when passing it to various functions, like Container_XML's getRawPage() function (which in turn calls Container's _getLangID() ). I didn't look through the whole source code but at least _getLangID() should accept a numeric 0 as language ID (i.e. don't rely purely on empty() ) or make the IDs start from 1 onwards (as one would expect in terms of portability to databases). Test script: --------------- http://dev.psix.org/translation2admin/

Comments

 [2007-10-07 10:29 UTC] quipo (Lorenzo Alberton)
Can you post a simple (covering just the actual problem) reproducing script? TIA
 [2007-10-07 17:41 UTC] clue (Christian Lück)
Sure, taken from the script posted above I'm basically issuing the following: [php] $info = array( 'lang_id' => '', 'name' => '', 'meta' => '', 'error_text' => '', 'encoding' => 'utf-8' ); $ret = $tr->addLang($info); [/php] (Those values are actually taken from POST and are the defaults if they're empty) $ret contains '(bool)true' and the corresponding container (XML in this case) is successfully modified. Issuing a '$langs = $tr->getLangs("ids");' next successfully returns an array of all available languages, including the newly created one, except for it's new ID being '(int)0' (counting upwards if it's already in use). Next, working with '$info = $tr->getLang($lang,"array");' ($lang being '(int)0' in this case) still works as it ought to. Then however, '$info = $tr->getLang($lang,"array");' doesn't work and returns a 'PEAR::Error' with the following message: 'No valid language set. Use Translation2::setLang().'. It's not only 'getLang' that's affected, but also at least '$value = $tr->getRaw($key,$page,$lang);' doesn't work as well. It seems all methods fail which rely on 'getRawPage()' (which in turn fails for obvious reasons because it relies on 'empty()' to verify the ID). Hope I made myself more clear this time and could provide the necessary information. If you need anything more just take a look at the script posted above or contact me and I'll happily help out.
 [2007-10-07 18:28 UTC] quipo (Lorenzo Alberton)
Thx, I've committed a fix to CVS. Please grab the new files and let me know if there's any issue left. TIA