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:

How do you run a phpt test from the command line?



.


Previous Comments:
------------------------------------------------------------------------
[2010-11-25 01:19:33] paj...@php.net

It would be very helpful if you can write it as phpt :)



See http://qa.php.net/write-test.php

------------------------------------------------------------------------
[2010-11-25 01:17:32] greno at verizon dot net

If it can pass the following tests on Linux then it should be Ok:



http://greno-misc.googlecode.com/files/testbindtextdomain.php





.

------------------------------------------------------------------------
[2010-11-25 00:44:22] paj...@php.net

"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"



It is not "just" a warning, it is exactly what I explained, php uses
chdir before you even get the hand (pls keep in mind TS and NTS sapi).



"bindtextdomain(domain, NULL) just needs to return whatever setting you
gave to it previously."



That's where it could be hard. However I could modify the patch (mines,
not the other) to:



1. make a path absolute only when a TS SAPI is used (php builds in TS
mode)

2. pass NULL when NULL is given, empty string may be considered as '.',
for BC reasons



Doing so will create no wtf for the users and it will do what you are
looking for.

------------------------------------------------------------------------
[2010-11-25 00:15:59] greno at verizon dot net

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 ).









.

------------------------------------------------------------------------
[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

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


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