Bug #53251 [Csd]: bindtextdomain with null directory doesn't return the previously set

From: Date: Wed, 02 Mar 2022 12:08:32 +0000
Subject: Bug #53251 [Csd]: bindtextdomain with null directory doesn't return the previously set
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240111@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53251&edit=1

 ID:                 53251
 Updated by:         cmb@php.net
 Reported by:        jeanseb at au-fil-du dot net
 Summary:            bindtextdomain with null directory doesn't return
                     the previously set
 Status:             Closed
 Type:               Bug
 Package:            Gettext related
 Operating System:   Debian 5.0.6
 PHP Version:        5.3.3
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> I'm running PHP Version 7.4.3 on Ubuntu 20.04.4 LTS.

The fix only targeted PHP 8.0 and higher.  Since PHP 7.4 is no
longer actively supported[1], the fix won't be backported.
Consider to upgrade to PHP 8.

[1] <https://www.php.net/supported-versions.php>


Previous Comments:
------------------------------------------------------------------------
[2022-03-02 12:03:51] dex at pirho dot net

Additionally, bind_textdomain_codeset is not returning the currently set encoding.

bind_textdomain_codeset('strings', 'UTF-8');
echo bind_textdomain_codeset('strings', NULL);

This code returns '' (nothing at all).

The bind_textdomain_codeset manual entry
(https://www.php.net/manual/en/function.bind-textdomain-codeset.php) states 'The code set. If
null, the currently set encoding is returned.'

------------------------------------------------------------------------
[2022-03-02 11:58:34] dex at pirho dot net

This still isn't working. I'm running PHP Version 7.4.3 on Ubuntu 20.04.4 LTS.

bindtextdomain('strings', '/var/www/html/locale/');
echo bindtextdomain($domain, NULL);

This code returns '/var/www/html'.

The bindtextdomain manual entry (https://www.php.net/manual/en/function.bindtextdomain.php) states
'The directory path. If null, the currently set directory is returned.'

------------------------------------------------------------------------
[2021-01-25 14:45:30] cmb@php.net

Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d319098b24342e9a4e2344dc7f588b74edcaa846
Log: Fix #53251: bindtextdomain with null dir doesn't return old value

------------------------------------------------------------------------
[2021-01-22 12:15:02] cmb@php.net

The following pull request has been associated:

Patch Name: Fix #53251: bindtextdomain with null dir doesn't return old value
On GitHub:  https://github.com/php/php-src/pull/6631
Patch:      https://github.com/php/php-src/pull/6631.patch

------------------------------------------------------------------------
[2021-01-22 11:45:09] cmb@php.net

The basic problem here is that neither bindtextdomain() nor
bind_textdomain_codeset() (the PHP functions) do actually
accept null for $directory and $codeset, respectively.  An empty
string is not null, and should not be treated as such, because
the respective C function also clearly distinguish between both.
bindtextdomain($domain, "") *binds* the textdomain to the VCWD,
while bindtextdomain($domain, NULL) is supposed to return the bound
directory.

Anyhow, the actual blocker for this bug fix was apparently the
discussion around the virtual CWD issues, which I do not really
understand.  If PHP's bindtextdomain() has been called to bind a
directory, that already was "corrected" by calling VCWD_REALPATH()
and as such is an absolute path.  If PHP's bindtextdomain() has
not yet been called, we should return bindtextdomain(3)'s return
value unmodified.

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


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

    https://bugs.php.net/bug.php?id=53251


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


Thread (49 messages)

« previous php.bugs (#240111) next »