|
24 | 24 | #include "../intl_error.h" |
25 | 25 | #include "../intl_common.h" |
26 | 26 | #include "converter_arginfo.h" |
| 27 | +#include "php_intl.h" |
27 | 28 |
|
28 | 29 | typedef struct _php_converter_object { |
29 | 30 | UConverter *src, *dest; |
@@ -370,7 +371,10 @@ static bool php_converter_set_encoding(php_converter_object *objval, |
370 | 371 | /* Should never happen */ |
371 | 372 | actual_encoding = "(unknown)"; |
372 | 373 | } |
373 | | - php_error_docref(NULL, E_WARNING, "Ambiguous encoding specified, using %s", actual_encoding); |
| 374 | + char *msg; |
| 375 | + spprintf(&msg, 0, "Ambiguous encoding specified, using %s", actual_encoding); |
| 376 | + intl_error_set(NULL, error, msg); |
| 377 | + efree(msg); |
374 | 378 | } else if (U_FAILURE(error)) { |
375 | 379 | if (objval) { |
376 | 380 | THROW_UFAILURE(objval, error); |
@@ -530,10 +534,23 @@ PHP_METHOD(UConverter, __construct) { |
530 | 534 | Z_PARAM_STRING_OR_NULL(src, src_len) |
531 | 535 | ZEND_PARSE_PARAMETERS_END(); |
532 | 536 |
|
533 | | - php_converter_set_encoding(objval, &(objval->src), src, src_len ); |
534 | | - php_converter_set_encoding(objval, &(objval->dest), dest, dest_len); |
| 537 | + const bool old_use_exception = INTL_G(use_exceptions); |
| 538 | + const zend_long old_error_level = INTL_G(error_level); |
| 539 | + INTL_G(use_exceptions) = true; |
| 540 | + INTL_G(error_level) = 0; |
| 541 | + if (UNEXPECTED(!php_converter_set_encoding(objval, &(objval->src), src, src_len))) { |
| 542 | + ZEND_ASSERT(EG(exception)); |
| 543 | + goto cleanup; |
| 544 | + } |
| 545 | + if (UNEXPECTED(!php_converter_set_encoding(objval, &(objval->dest), dest, dest_len))) { |
| 546 | + ZEND_ASSERT(EG(exception)); |
| 547 | + goto cleanup; |
| 548 | + } |
535 | 549 | php_converter_resolve_callback(&objval->to_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("toUCallback")); |
536 | 550 | php_converter_resolve_callback(&objval->from_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("fromUCallback")); |
| 551 | +cleanup: |
| 552 | + INTL_G(use_exceptions) = old_use_exception; |
| 553 | + INTL_G(error_level) = old_error_level; |
537 | 554 | } |
538 | 555 | /* }}} */ |
539 | 556 |
|
|
0 commit comments