Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ PHP 8.7 UPGRADE NOTES
curl_setopt() return false, instead of being silently interpreted as a
combination of redirect types.

- Gettext:
. bindtextdomain() now throws a ValueError when $directory is "0", like
textdomain() does for its $domain. It previously treated it as an empty
string and bound the domain to the current directory.

- PDO:
. PDOStatement::bindColumn() now throws a ValueError when the column name is
not present in the result set. It previously reported the condition
Expand Down
6 changes: 5 additions & 1 deletion ext/gettext/gettext.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ PHP_FUNCTION(bindtextdomain)
RETURN_STRING(btd_result);
}

if (ZSTR_LEN(dir) != 0 && !zend_string_equals_literal(dir, "0")) {
if (ZSTR_LEN(dir) != 0) {
if (zend_string_equals_literal(dir, "0")) {
zend_argument_value_error(2, "cannot be zero");
RETURN_THROWS();
}
if (!VCWD_REALPATH(ZSTR_VAL(dir), dir_name)) {
RETURN_FALSE;
}
Expand Down
20 changes: 20 additions & 0 deletions ext/gettext/tests/bindtextdomain_dir_zero.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
bindtextdomain() throws a ValueError when the directory is "0"
--EXTENSIONS--
gettext
--FILE--
<?php

try {
bindtextdomain('app', '0');
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}

chdir(__DIR__);
var_dump(bindtextdomain('app', '') === realpath(__DIR__));

?>
--EXPECT--
bindtextdomain(): Argument #2 ($directory) cannot be zero
bool(true)
Loading