Edit report at http://bugs.php.net/bug.php?id=53251&edit=1
ID: 53251 Updated by: paj...@php.net Reported by: jeanseb at au-fil-du dot net Summary: bindtextdomain with null directory doesn't return the previously set Status: Open Type: Bug Package: Gettext related Operating System: Debian 5.0.6 PHP Version: 5.3.3 Block user comment: N Private report: N New Comment: hi, About the relative directories, what's about making them absolute before passing them to gettext? The problem here is that the script CWD may not be the library (apache or whatever else) CWD, that's the typical usage of the virtual CWD. Looking at the current implementation: - has '0' any special meaning for bindtextdomain? if not and if it is about testing empty string, this code is wrong and ugly :) - If an empty string is given, passing VCWD_GETCWD results should be the right thing to do - the current code has a leak, dir_name should be freed if VCWD_GETCWD called succeeded About including it in 5.3.4, it is too late. However trunk is open, so please try to agree on the behavior(s) and update the patch accordingly. Previous Comments: ------------------------------------------------------------------------ [2010-11-18 23:10:37] greno at verizon dot net It's not whether there is a use case or not, that's how bindtextdomain is defined to work. The PHP implementation needs to work exactly like the GNU implementation and other implementations in other languages such as python for example, and right now it doesn't. That's why I pointed out the fact that relative directories are valid and in the case where a call is made with a NULL directory argument but no previous setting was made, that the correct behavior is to return the default locale directory for the system. ------------------------------------------------------------------------ [2010-11-18 22:31:20] jeanseb at au-fil-du dot net I haven't svn access yet and I prefer that someone with more background review this patch because it introduce an bc break. For the relative path, I don't see any benefits to change this behaviour. Can you produce a real use case. Thank's ------------------------------------------------------------------------ [2010-11-18 21:59:36] greno at verizon dot net Please fix this bug for 5.2.15 as well as 5.3.3. This flaw prevents being able to query the existing directory setting for the domain and in turn this destroys any ability to nest usage of different translation stores. . ------------------------------------------------------------------------ [2010-11-07 15:52:33] greno at verizon dot net And to clarify regarding the case where no previous bindtextdomain call was made prior to the bindtextdomain call with a NULL directory argument. In this case bindtextdomain should return the default locale directory for the system. In the case of Linux this is '/usr/share/locale'. I tested this again using python and it produces the correct result: # cat test2.py #!/usr/bin/env python from gettext import * ### no previous bindtextdomain call in effect print bindtextdomain("messages",None); # python test2.py /usr/share/locale ------------------------------------------------------------------------ [2010-11-07 15:12:00] greno at verizon dot net The previous expected PHP results shown are not correct for 'bindtextdomain'. The expected results should be: getcwd() : /home/jeanseb bindtextdomain("messages", "./locale") : ./locale bindtextdomain("messages",NULL) : ./locale When I test using python 'bindtextdomain' I get the correct result: # cat test.py #!/usr/bin/env python from gettext import * print bindtextdomain("messages", "./locale"); print bindtextdomain("messages",None); # python test.py ./locale ./locale Relative base directories are allowed. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=53251 -- Edit this bug report at http://bugs.php.net/bug.php?id=53251&edit=1