Edit report at http://bugs.php.net/bug.php?id=53251&edit=1

 ID:                 53251
 Comment by:         greno at verizon dot net
 Reported by:        jeanseb at au-fil-du dot net
 Summary:            bindtextdomain with null directory doesn't return
                     the previously set
 Status:             Feedback
 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:

That warning is just to make sure that people understand that when you
use relative domain dir setting that if you chdir() then the domain dir
is going to follow as well since it is relative.  I mean it shouldn't
even be necessary to give such a warning.  Only total newbies would not
understand how relative and absolute would behave.





In many cases using relative setting is exactly what you want because
you have a bunch of standalone apps with their own translation stores
and you are just integrating as-is.  So relative mapping works very well
in this case.



If you are building one humongous app and you want all translations from
everywhere to be in one translation store then absolute mapping makes
sense in that case.



The are good and valid use cases for both types of bindings.



bindtextdomain(domain, NULL) just needs to return whatever setting you
gave to it previously.  If it was relative then you return the exact
same relative setting (eg: ./locale ) and if it was absolute then you
return the exact same absolute setting (eg: /absolutepath/locale ).









.


Previous Comments:
------------------------------------------------------------------------
[2010-11-25 00:00:34] paj...@php.net

If you read the code you will see that dir_len == 0  happens when you
pass NULL or "" to the function.



We don't do any detection or whatever else in there. This is a pure
binding, there is no logic in the PHP extension and we only rely on the
underlying library to do the right thing with what the users provide.
The only thing that we did not do was not to pass NULL when the user
actually gives us NULL (or empty string, can be improved later to
actually detect both separately).



Now, reading the bindtextdomain API reference:



"Note: Applications that wish to use chdir() should always use absolute
pathnames to avoid misadvertently selecting the wrong or non-existant
directory."



That pretty much confirms what I've been saying earlier.



http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/baselib-bindtextdomain.html

------------------------------------------------------------------------
[2010-11-24 23:51:25] greno at verizon dot net

I looked at the patch earlier.



It does not do what is necessary.



When the user calls bindtextdomain(domain, NULL) it needs to do one of
two things.  If there was no previous bindtextdomain call made then it
should return the default locale directory for the system.  Otherwise if
bindtextdomain was called previously then it should return that setting.
 



There are about 3-4 places above where I've outlined the correct
behavior in detail.  Can you please tailor the behavior to match those? 
Thanks.



And who cares about dir length = 0?  What does that have to do with
returning the correct setting?  You do not even need to be looking at
any directory length.  If you see a NULL there you go, that's the key
that tells you to return existing setting.





.

------------------------------------------------------------------------
[2010-11-24 23:44:30] paj...@php.net

It is TS on windows now (our builds). But the key part is in my question
in the 2nd comment. Questions like to be answered from time to time you
know :)

------------------------------------------------------------------------
[2010-11-24 23:43:15] greno at verizon dot net

Gettext is not thread-safe.



You cannot run PHP gettext in anything but a non-threaded CGI or prefork
mode.



We run our webservers prefork to support PHP gettext.  



And for any production webserver it is best to run either CGI or prefork
so that your connections are completely isolated.



And PHP gettext performs correctly when used w/CGI or preforking
webservers.





.

------------------------------------------------------------------------
[2010-11-24 23:39:00] paj...@php.net

Besides our little difference about virtual CWD, please try the attached
patch against 5.3. It checks if the given directory is empty or NULL
(dir length == 0) and if yes, calls bindtextdomain with NULL.



Is it what you expect?

------------------------------------------------------------------------


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

Reply via email to