Merge branch 'PHP-8.3' into PHP-8.4

This commit is contained in:
David Carlier 2025-01-17 22:25:24 +00:00
commit 05a1c04c43
No known key found for this signature in database
GPG key ID: 2FB76A8CE6CD2B41
2 changed files with 41 additions and 4 deletions

View file

@ -384,20 +384,23 @@ static bool php_converter_set_encoding(php_converter_object *objval,
if (objval) {
THROW_UFAILURE(objval, "ucnv_open", error);
} else {
php_error_docref(NULL, E_WARNING, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
char *msg;
spprintf(&msg, 0, "Error setting encoding: %d - %s", (int)error, u_errorName(error));
intl_error_set(NULL, error, msg, 1);
efree(msg);
}
return 0;
return false;
}
if (objval && !php_converter_set_callbacks(objval, cnv)) {
return 0;
return false;
}
if (*pcnv) {
ucnv_close(*pcnv);
}
*pcnv = cnv;
return 1;
return true;
}
/* }}} */

View file

@ -0,0 +1,34 @@
--TEST--
GH-17469: UConverter::transcode() raises always E_WARNING regardless of INI settings
--SKIPIF--
<?php
if (PHP_OS_FAMILY === "Windows") die("skip currently unsupported on Windows");
?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.use_exceptions", 0);
UConverter::transcode("\x0a", 'nein!!', 'UTF-8');
UConverter::transcode("\x0a", 'UTF-16BE', 'da!');
ini_set("intl.error_level", 0);
ini_set("intl.use_exceptions", 1);
try {
UConverter::transcode("\x0a", 'nein!!', 'UTF-8');
} catch (IntlException $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
UConverter::transcode("\x0a", 'UTF-16BE', 'da!');
} catch (IntlException $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d
Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line 5
Error setting encoding: 4 - U_FILE_ACCESS_ERROR
Error setting encoding: 4 - U_FILE_ACCESS_ERROR