Skip to content

Commit 709c0a9

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 7dbfacb + 05a1c04 commit 709c0a9

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
@@ -374,20 +374,23 @@ static bool php_converter_set_encoding(php_converter_object *objval,
374374
if (objval) {
375375
THROW_UFAILURE(objval, "ucnv_open", error);
376376
} else {
377-
php_error_docref(NULL, E_WARNING, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
377+
char *msg;
378+
spprintf(&msg, 0, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
379+
intl_error_set(NULL, error, msg, 1);
380+
efree(msg);
378381
}
379-
return 0;
382+
return false;
380383
}
381384

382385
if (objval && !php_converter_set_callbacks(objval, cnv)) {
383-
return 0;
386+
return false;
384387
}
385388

386389
if (*pcnv) {
387390
ucnv_close(*pcnv);
388391
}
389392
*pcnv = cnv;
390-
return 1;
393+
return true;
391394
}
392395
/* }}} */
393396

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)