Skip to content

Commit 05a1c04

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 0b04061 + a1d1269 commit 05a1c04

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

ext/intl/converter/converter.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,20 +384,23 @@ static bool php_converter_set_encoding(php_converter_object *objval,
384384
if (objval) {
385385
THROW_UFAILURE(objval, "ucnv_open", error);
386386
} else {
387-
php_error_docref(NULL, E_WARNING, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
387+
char *msg;
388+
spprintf(&msg, 0, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
389+
intl_error_set(NULL, error, msg, 1);
390+
efree(msg);
388391
}
389-
return 0;
392+
return false;
390393
}
391394

392395
if (objval && !php_converter_set_callbacks(objval, cnv)) {
393-
return 0;
396+
return false;
394397
}
395398

396399
if (*pcnv) {
397400
ucnv_close(*pcnv);
398401
}
399402
*pcnv = cnv;
400-
return 1;
403+
return true;
401404
}
402405
/* }}} */
403406

ext/intl/tests/gh17469.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
GH-17469: UConverter::transcode() raises always E_WARNING regardless of INI settings
3+
--SKIPIF--
4+
<?php
5+
if (PHP_OS_FAMILY === "Windows") die("skip currently unsupported on Windows");
6+
?>
7+
--FILE--
8+
<?php
9+
ini_set("intl.error_level", E_WARNING);
10+
ini_set("intl.use_exceptions", 0);
11+
UConverter::transcode("\x0a", 'nein!!', 'UTF-8');
12+
UConverter::transcode("\x0a", 'UTF-16BE', 'da!');
13+
14+
ini_set("intl.error_level", 0);
15+
ini_set("intl.use_exceptions", 1);
16+
17+
try {
18+
UConverter::transcode("\x0a", 'nein!!', 'UTF-8');
19+
} catch (IntlException $e) {
20+
echo $e->getMessage(), PHP_EOL;
21+
}
22+
try {
23+
UConverter::transcode("\x0a", 'UTF-16BE', 'da!');
24+
} catch (IntlException $e) {
25+
echo $e->getMessage(), PHP_EOL;
26+
}
27+
?>
28+
--EXPECTF--
29+
30+
Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d
31+
32+
Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line 5
33+
Error setting encoding: 4 - U_FILE_ACCESS_ERROR
34+
Error setting encoding: 4 - U_FILE_ACCESS_ERROR

0 commit comments

Comments
 (0)