From 339f46237d82cec13d2afe01acfa3046a1b48798 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 17 Apr 2011 21:56:26 +0000 Subject: [PATCH] implement FR #54540 - Allow loading of arbitrary resource bundles when fallback is disabled --- NEWS | 4 ++++ .../resourcebundle/resourcebundle_class.c | 6 +++++- ext/intl/tests/resourcebundle_create.phpt | 2 +- ext/intl/tests/resourcebundle_internal.phpt | 19 +++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 ext/intl/tests/resourcebundle_internal.phpt diff --git a/NEWS b/NEWS index 2577a1fbf3..a9bea7905b 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,10 @@ PHP NEWS - Filter extension: . Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). (Ilia) +- intl extension: + . Implemented FR #54540 (Allow loading of arbitrary resource bundles when + fallback is disabled). (David Zuelke, Stas) + - LDAP extension: . Fixed bug #53339 (Fails to build when compilng with gcc 4.5 and DSO libraries). (Clint Byrum, Raphael) diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index a8a4bf1c86..67d0e55ddd 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -102,7 +102,11 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); - rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb)); + if (fallback) { + rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb)); + } else { + rb->me = ures_openDirect(bundlename, locale, &INTL_DATA_ERROR_CODE(rb)); + } INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle"); diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt index 4d96d3eff7..2bf4f556a8 100644 --- a/ext/intl/tests/resourcebundle_create.phpt +++ b/ext/intl/tests/resourcebundle_create.phpt @@ -57,6 +57,6 @@ ResourceBundle Object -127: U_USING_DEFAULT_WARNING NULL - -127: resourcebundle_ctor: Cannot load libICU resource '%s/resourcebundle' without fallback from en_US to root: U_USING_DEFAULT_WARNING + 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR NULL 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR diff --git a/ext/intl/tests/resourcebundle_internal.phpt b/ext/intl/tests/resourcebundle_internal.phpt new file mode 100644 index 0000000000..7aefd854ce --- /dev/null +++ b/ext/intl/tests/resourcebundle_internal.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test ResourceBundle::__construct() with internal ICU bundles +--SKIPIF-- + +--FILE-- +get('Countries')->get('DE')); + +$b = new ResourceBundle('icuver', 'ICUDATA'); +var_dump($b->get('ICUVersion') !== NULL); + +$b = new ResourceBundle('supplementalData', 'ICUDATA', false); +var_dump($b->get('cldrVersion') !== NULL); +?> +--EXPECTF-- +string(11) "Deutschland" +bool(true) +bool(true) -- 2.50.1