php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #65163
Patch collator_create revision 2013-06-28 21:14 UTC by poinsot dot julien at gmail dot co

Patch collator_create for I18N and L10N related Bug #65163

Patch version 2013-06-28 21:14 UTC

Return to Bug #65163 | Download this patch
Patch Revisions:

Developer: poinsot.julien@gmail.co

diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c
index b2a8c7f..8f1783f 100644
--- a/ext/intl/collator/collator_create.c
+++ b/ext/intl/collator/collator_create.c
@@ -27,16 +27,17 @@
 /* {{{ */
 static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
 {
-	char*            locale;
+	char*            locale = "";
 	int              locale_len = 0;
 	zval*            object;
+	zval*            zname;
 	Collator_object* co;
 
 	intl_error_reset( NULL TSRMLS_CC );
 	object = return_value;
 	/* Parse parameters. */
-	if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
-		&locale, &locale_len ) == FAILURE )
+	if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "z", &zname ) == FAILURE
+		|| ( Z_TYPE_P(zname) != IS_NULL && Z_TYPE_P(zname) != IS_STRING ) )
 	{
 		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
 			"collator_create: unable to parse input params", 0 TSRMLS_CC );
@@ -47,8 +48,11 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
 	INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
 	COLLATOR_METHOD_FETCH_OBJECT;
 
-	if(locale_len == 0) {
+	if( Z_TYPE_P(zname) == IS_NULL ) {
 		locale = intl_locale_get_default(TSRMLS_C);
+	} else /*if (Z_TYPE_P(zname) == IS_STRING)*/ {
+		locale = Z_STRVAL_P(zname);
+		locale_len = Z_STRLEN_P(zname);
 	}
 
 	/* Open ICU collator. */
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat May 21 12:05:47 2022 UTC