Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ PHP NEWS
. Upgrade xxHash to 0.8.2. (timwolla)

- Intl:
. Fixed malformed ResourceBundle::get() error message when fallback is
disabled. (Weilin Du)
. Added IntlNumberRangeFormatter class to format an interval of two numbers
with a given skeleton, locale, collapse type and identity fallback.
(BogdanUngureanu)
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ PHP 8.6 UPGRADE NOTES
. UConverter::transcode() now rejects from_subst and to_subst option values
longer than 127 bytes instead of silently truncating the length before
passing it to ICU.
. ResourceBundle::get() and resourcebundle_get() now report fallback-disabled
resource lookups with "without fallback to <locale>" instead of the
malformed "without fallback from to <locale>".

- PCNTL:
. pcntl_alarm() now raises a ValueError if the seconds argument is
Expand Down
6 changes: 3 additions & 3 deletions ext/intl/resourcebundle/resourcebundle_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ static zval *resource_bundle_array_fetch(
}

if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
UErrorCode icuerror;
UErrorCode icuerror = U_ZERO_ERROR;
const char * locale = ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &icuerror );
if (is_numeric) {
spprintf(&pbuf, 0, "Cannot load element %d without fallback from to %s", index, locale);
spprintf(&pbuf, 0, "Cannot load element %d without fallback to %s", index, locale);
} else {
spprintf(&pbuf, 0, "Cannot load element '%s' without fallback from to %s", key, locale);
spprintf(&pbuf, 0, "Cannot load element '%s' without fallback to %s", key, locale);
}
intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf);
efree(pbuf);
Expand Down
19 changes: 19 additions & 0 deletions ext/intl/tests/resourcebundle_get_without_fallback.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
ResourceBundle::get() rejects fallback results when fallback is disabled with correct error message
--EXTENSIONS--
intl
--FILE--
<?php
include "resourcebundle.inc";

$bundle = new ResourceBundle('es', BUNDLE);
echo debug($bundle->get('testint', false));

$bundle = resourcebundle_create('es', BUNDLE);
echo debug(resourcebundle_get($bundle, 'testint', false));
?>
--EXPECTF--
NULL
%i: Cannot load element 'testint' without fallback to %s: U_USING_%s_WARNING
NULL
%i: Cannot load element 'testint' without fallback to %s: U_USING_%s_WARNING
Loading