We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2d20f4 commit b341036Copy full SHA for b341036
NEWS
@@ -52,8 +52,8 @@ PHP NEWS
52
. Removed the deprecated inet_ntoa call support. (David Carlier)
53
54
- Gettext:
55
- . bind_textdomain_codeset now throws an exception on empty domain.
56
- (David Carlier)
+ . bind_textdomain_codeset, textdomain and d(*)gettext functions
+ now throw an exception on empty domain. (David Carlier)
57
58
- Hash:
59
. Changed return type of hash_update() to true. (nielsdos)
UPGRADING
@@ -323,7 +323,8 @@ PHP 8.4 UPGRADE NOTES
323
Previously, the return type was bool but only true could be returned in practice.
324
325
326
- . bind_textdomain_codeset now throws an exception if the domain's argument is empty.
+ . bind_textdomain_codeset, textdomain and d(*)gettext functions now throw an exception
327
+ if the domain argument is empty.
328
329
330
. Changed the return type of hash_update() to true. It was already the case that only
ext/gettext/gettext.c
@@ -54,6 +54,9 @@ ZEND_GET_MODULE(php_gettext)
if (UNEXPECTED(domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH)) { \
zend_argument_value_error(_arg_num, "is too long"); \
RETURN_THROWS(); \
+ } else if (domain_len == 0) { \
+ zend_argument_value_error(_arg_num, "cannot be empty"); \
+ RETURN_THROWS(); \
60
}
61
62
#define PHP_GETTEXT_LENGTH_CHECK(_arg_num, check_len) \
@@ -85,8 +88,11 @@ PHP_FUNCTION(textdomain)
85
88
RETURN_THROWS();
86
89
87
90
- if (domain != NULL && ZSTR_LEN(domain) != 0 && !zend_string_equals_literal(domain, "0")) {
91
+ if (domain != NULL) {
92
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
93
+ }
94
+
95
+ if (domain != NULL && !zend_string_equals_literal(domain, "0")) {
96
domain_name = ZSTR_VAL(domain);
97
98
@@ -179,11 +185,6 @@ PHP_FUNCTION(bindtextdomain)
179
185
180
186
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
181
187
182
- if (!domain_len) {
183
- zend_argument_value_error(1, "cannot be empty");
184
- RETURN_THROWS();
- }
-
188
if (dir == NULL) {
189
RETURN_STRING(bindtextdomain(domain, NULL));
190
@@ -292,11 +293,6 @@ PHP_FUNCTION(bind_textdomain_codeset)
292
293
294
295
296
297
298
299
300
retval = bind_textdomain_codeset(domain, codeset);
301
302
if (!retval) {
ext/gettext/tests/dcngettext.phpt
@@ -13,8 +13,18 @@ var_dump(dcngettext(1,1,1,1,1));
13
var_dump(dcngettext("test","test","test",1,1));
14
var_dump(dcngettext("test","test","test",0,1));
15
var_dump(dcngettext("test","test","test",-1,-1));
16
-var_dump(dcngettext("","","",1,1));
17
-var_dump(dcngettext("","","",0,1));
+try {
18
+ dcngettext("","","",1,1);
19
+} catch (\ValueError $e) {
20
+ echo $e->getMessage() . PHP_EOL;
21
+}
22
23
24
+ dcngettext("","","",0,1);
25
26
27
28
29
echo "Done\n";
30
?>
@@ -23,6 +33,6 @@ string(1) "1"
33
string(4) "test"
34
35
-string(0) ""
36
+dcngettext(): Argument #1 ($domain) cannot be empty
37
38
Done
ext/gettext/tests/gettext_textdomain-retval.phpt
@@ -18,11 +18,18 @@ bindtextdomain ("messages", "./locale");
echo textdomain('test'), "\n";
echo textdomain(null), "\n";
echo textdomain('foo'), "\n";
+ textdomain('');
+ echo $e->getMessage();
--EXPECT--
test
31
foo
32
+textdomain(): Argument #1 ($domain) cannot be empty
--CREDITS--
Christian Weiske, [email protected]
PHP Testfest Berlin 2009-05-09
0 commit comments