Skip to content

Throw a ValueError for a "0" directory in bindtextdomain() - #25699

Open
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/bindtextdomain-zero-directory-valueerror
Open

lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/bindtextdomain-zero-directory-valueerror

Conversation

@lacatoire

@lacatoire lacatoire commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

bindtextdomain() still treats a $directory of "0" like an empty string and binds the domain to the current directory. This is a leftover of the PHP 3 era, when arguments were converted to strings and "0" meant no value (strcmp(dir, "") && strcmp(dir, "0") since the first version of the extension). textdomain() was cleaned up for the same case in GH-13582 and throws a ValueError, but this function was left out. Do the same here.
To reproduce:

mkdir('0');
var_dump(bindtextdomain('app', '0') === realpath('0'));

Before (master): bool(false), the domain is bound to the current directory.

After: ValueError: bindtextdomain(): Argument #2 ($directory) cannot be zero

bindtextdomain() still treated $directory "0" like an empty string and silently bound the domain to the current directory, a leftover of the PHP 3 era when "0" meant no value. textdomain() already throws a ValueError for "0"; do the same here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant