summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-05-24 13:52:06 +0200
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-05-24 13:52:06 +0200
commita03f2e381421e74e34cb1f9e44e204589edec4de (patch)
tree88e11b9ea06f3c8438b375f356668a11a6ba85db
parent674a04dfc7e3d2d97f4d755f0ecab42f265ed6a0 (diff)
parent92039fed22cd68405589cf6df3af58b9beaddb16 (diff)
downloadphp-git-a03f2e381421e74e34cb1f9e44e204589edec4de.tar.gz
Merge branch '5.4'
Conflicts: UPGRADING
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c22
-rw-r--r--ext/intl/tests/resourcebundle_null_mandatory_args.phpt26
2 files changed, 41 insertions, 7 deletions
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index 5471e5b3f6..e3f8252b91 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -91,7 +91,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
intl_error_reset( NULL TSRMLS_CC );
- if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "ss|b",
+ if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s!s!|b",
&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -101,6 +101,10 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
}
INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
+
+ if (locale == NULL) {
+ locale = intl_locale_get_default(TSRMLS_C);
+ }
if (fallback) {
rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
@@ -110,13 +114,17 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");
- if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
- intl_errors_set_code( NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC );
- spprintf( &pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource '%s' without fallback from %s to %s",
- bundlename, locale, ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)) );
- intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC );
+ if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING ||
+ INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
+ intl_errors_set_code(NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC);
+ spprintf(&pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource "
+ "'%s' without fallback from %s to %s",
+ bundlename ? bundlename : "(default data)", locale,
+ ures_getLocaleByType(
+ rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)));
+ intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC);
efree(pbuf);
- zval_dtor( return_value );
+ zval_dtor(return_value);
RETURN_NULL();
}
}
diff --git a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt
new file mode 100644
index 0000000000..8fde61bd21
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt
@@ -0,0 +1,26 @@
+--TEST--
+IntlCalendar::setTime() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$r = new ResourceBundle('en_US', NULL);
+$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
+var_dump($c);
+
+ini_set('intl.default_locale', 'pt_PT');
+$r = new ResourceBundle(NULL, NULL);
+$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
+var_dump($c);
+?>
+==DONE==
+--EXPECT--
+string(14) "h:mm:ss a zzzz"
+string(12) "H:mm:ss zzzz"
+==DONE==