Skip to content

Commit

Permalink
Merge branch 'PHP-8.3' into PHP-8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Jan 17, 2025
2 parents 0b04061 + a1d1269 commit 05a1c04
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ext/intl/converter/converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
/* }}} */

Expand Down
34 changes: 34 additions & 0 deletions ext/intl/tests/gh17469.phpt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 05a1c04

Please sign in to comment.