fa                                       Thu, 03 Nov 2011 16:20:11 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=318744

Log:
Redid the fix for #60192 with suggestions by Pierre and Kalle

Bug: https://bugs.php.net/60192 (Closed) SegFault when Collator not constructed 
properly
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/intl/collator/collator_compare.c
    U   php/php-src/branches/PHP_5_3/ext/intl/collator/collator_locale.c
    U   php/php-src/branches/PHP_5_3/ext/intl/collator/collator_sort.c
    U   php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-compare.phpt
    U   php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getlocale.phpt
    U   php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getsortkey.phpt
    U   php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sort.phpt
    U   
php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sortwithsortkeys.phpt
    U   php/php-src/branches/PHP_5_4/ext/intl/collator/collator_compare.c
    U   php/php-src/branches/PHP_5_4/ext/intl/collator/collator_locale.c
    U   php/php-src/branches/PHP_5_4/ext/intl/collator/collator_sort.c
    U   php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-compare.phpt
    U   php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getlocale.phpt
    U   php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getsortkey.phpt
    U   php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sort.phpt
    U   
php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sortwithsortkeys.phpt
    U   php/php-src/trunk/ext/intl/collator/collator_compare.c
    U   php/php-src/trunk/ext/intl/collator/collator_locale.c
    U   php/php-src/trunk/ext/intl/collator/collator_sort.c
    U   php/php-src/trunk/ext/intl/tests/bug60192-compare.phpt
    U   php/php-src/trunk/ext/intl/tests/bug60192-getlocale.phpt
    U   php/php-src/trunk/ext/intl/tests/bug60192-getsortkey.phpt
    U   php/php-src/trunk/ext/intl/tests/bug60192-sort.phpt
    U   php/php-src/trunk/ext/intl/tests/bug60192-sortwithsortkeys.phpt

Modified: php/php-src/branches/PHP_5_3/ext/intl/collator/collator_compare.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/collator/collator_compare.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/collator/collator_compare.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -58,7 +58,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Compare given strings (converting them to UTF-16 first).
 	 */
@@ -99,10 +107,6 @@
 		RETURN_FALSE;
 	}

-	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
-
 	/* Then compare them. */
 	result = ucol_strcoll(
 		co->ucoll,

Modified: php/php-src/branches/PHP_5_3/ext/intl/collator/collator_locale.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/collator/collator_locale.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/collator/collator_locale.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -52,7 +52,12 @@
 	COLLATOR_METHOD_FETCH_OBJECT;

 	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
+		RETURN_FALSE;
 	}

 	/* Get locale by specified type. */

Modified: php/php-src/branches/PHP_5_3/ext/intl/collator/collator_sort.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/collator/collator_sort.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/collator/collator_sort.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -74,7 +74,10 @@
 		co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );

 		if (!co || !co->ucoll) {
-			php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
+			intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+			intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+				"Object not initialized", 0 TSRMLS_CC );
+			php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
 		}

 		/* Compare the strings using ICU. */
@@ -391,7 +394,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Sort specified array.
 	 */
@@ -445,10 +456,6 @@
 		/* Get sort key, reallocating the buffer if needed. */
 		bufLeft = sortKeyBufSize - sortKeyBufOffset;

-		if (!co || !co->ucoll) {
-			php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-		}
-
 		sortKeyLen = ucol_getSortKey( co->ucoll,
 									  utf16_buf,
 									  utf16_len,
@@ -559,7 +566,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Compare given strings (converting them to UTF-16 first).
 	 */
@@ -579,10 +594,6 @@
 		RETURN_FALSE;
 	}

-	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
-
 	key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0);
 	if(!key_len) {
 		efree( ustr );

Modified: php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-compare.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-compare.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-compare.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -6,7 +6,6 @@
 ?>
 --FILE--
 <?php
-
 class Collator2 extends Collator{
 	public function __construct() {
 		// ommitting parent::__construct($someLocale);
@@ -14,7 +13,7 @@
 }

 $c = new Collator2();
-$c->compare('h', 'H');
+$a = $c->compare('h', 'H');
 --EXPECTF--

-Fatal error: Collator::compare(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::compare(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getlocale.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getlocale.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getlocale.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -17,4 +17,4 @@
 $c->getLocale(Locale::ACTUAL_LOCALE);
 --EXPECTF--

-Fatal error: Collator::getLocale(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getLocale(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getsortkey.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getsortkey.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-getsortkey.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -17,4 +17,4 @@
 $c->getSortKey('h');
 --EXPECTF--

-Fatal error: Collator::getSortKey(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getSortKey(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sort.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sort.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sort.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -18,4 +18,4 @@
 $c->sort($a);
 --EXPECTF--

-Fatal error: Collator::sort(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sort(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sortwithsortkeys.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sortwithsortkeys.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_3/ext/intl/tests/bug60192-sortwithsortkeys.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -18,4 +18,4 @@
 $c->sortWithSortKeys($a);
 --EXPECTF--

-Fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_4/ext/intl/collator/collator_compare.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/collator/collator_compare.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/collator/collator_compare.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -58,7 +58,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Compare given strings (converting them to UTF-16 first).
 	 */
@@ -99,10 +107,6 @@
 		RETURN_FALSE;
 	}

-	if (!co || !co->ucoll) {
-	php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
-
 	/* Then compare them. */
 	result = ucol_strcoll(
 		co->ucoll,

Modified: php/php-src/branches/PHP_5_4/ext/intl/collator/collator_locale.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/collator/collator_locale.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/collator/collator_locale.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -52,7 +52,12 @@
 	COLLATOR_METHOD_FETCH_OBJECT;

 	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
+		RETURN_FALSE;
 	}

 	/* Get locale by specified type. */

Modified: php/php-src/branches/PHP_5_4/ext/intl/collator/collator_sort.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/collator/collator_sort.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/collator/collator_sort.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -73,9 +73,12 @@
 		/* Fetch collator object. */
 		co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );

-	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
+		if (!co || !co->ucoll) {
+			intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+			intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+				"Object not initialized", 0 TSRMLS_CC );
+			php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+		}

 		/* Compare the strings using ICU. */
 		result->value.lval = ucol_strcoll(
@@ -391,7 +394,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Sort specified array.
 	 */
@@ -445,10 +456,6 @@
 		/* Get sort key, reallocating the buffer if needed. */
 		bufLeft = sortKeyBufSize - sortKeyBufOffset;

-		if (!co || !co->ucoll) {
-			php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-		}
-
 		sortKeyLen = ucol_getSortKey( co->ucoll,
 									  utf16_buf,
 									  utf16_len,
@@ -559,7 +566,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Compare given strings (converting them to UTF-16 first).
 	 */
@@ -579,10 +594,6 @@
 		RETURN_FALSE;
 	}

-	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
-
 	key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0);
 	if(!key_len) {
 		efree( ustr );

Modified: php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-compare.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-compare.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-compare.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -6,7 +6,6 @@
 ?>
 --FILE--
 <?php
-
 class Collator2 extends Collator{
 	public function __construct() {
 		// ommitting parent::__construct($someLocale);
@@ -14,7 +13,7 @@
 }

 $c = new Collator2();
-$c->compare('h', 'H');
+$a = $c->compare('h', 'H');
 --EXPECTF--

-Fatal error: Collator::compare(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::compare(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getlocale.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getlocale.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getlocale.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -17,4 +17,4 @@
 $c->getLocale(Locale::ACTUAL_LOCALE);
 --EXPECTF--

-Fatal error: Collator::getLocale(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getLocale(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getsortkey.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getsortkey.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-getsortkey.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -17,4 +17,4 @@
 $c->getSortKey('h');
 --EXPECTF--

-Fatal error: Collator::getSortKey(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getSortKey(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sort.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sort.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sort.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -18,4 +18,4 @@
 $c->sort($a);
 --EXPECTF--

-Fatal error: Collator::sort(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sort(): Object not initialized in %s on line %d

Modified: php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sortwithsortkeys.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sortwithsortkeys.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/branches/PHP_5_4/ext/intl/tests/bug60192-sortwithsortkeys.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -18,4 +18,4 @@
 $c->sortWithSortKeys($a);
 --EXPECTF--

-Fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d

Modified: php/php-src/trunk/ext/intl/collator/collator_compare.c
===================================================================
--- php/php-src/trunk/ext/intl/collator/collator_compare.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/collator/collator_compare.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -58,7 +58,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Compare given strings (converting them to UTF-16 first).
 	 */
@@ -99,10 +107,6 @@
 		RETURN_FALSE;
 	}

-	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
-
 	/* Then compare them. */
 	result = ucol_strcoll(
 		co->ucoll,

Modified: php/php-src/trunk/ext/intl/collator/collator_locale.c
===================================================================
--- php/php-src/trunk/ext/intl/collator/collator_locale.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/collator/collator_locale.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -52,7 +52,12 @@
 	COLLATOR_METHOD_FETCH_OBJECT;

 	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
+		RETURN_FALSE;
 	}

 	/* Get locale by specified type. */

Modified: php/php-src/trunk/ext/intl/collator/collator_sort.c
===================================================================
--- php/php-src/trunk/ext/intl/collator/collator_sort.c	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/collator/collator_sort.c	2011-11-03 16:20:11 UTC (rev 318744)
@@ -73,10 +73,14 @@
 		/* Fetch collator object. */
 		co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );

-	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
+		if (!co || !co->ucoll) {
+			intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+			intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+				"Object not initialized", 0 TSRMLS_CC );
+			php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		}
+
 		/* Compare the strings using ICU. */
 		result->value.lval = ucol_strcoll(
 				co->ucoll,
@@ -391,7 +395,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Sort specified array.
 	 */
@@ -445,10 +457,6 @@
 		/* Get sort key, reallocating the buffer if needed. */
 		bufLeft = sortKeyBufSize - sortKeyBufOffset;

-		if (!co || !co->ucoll) {
-			php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-		}
-
 		sortKeyLen = ucol_getSortKey( co->ucoll,
 									  utf16_buf,
 									  utf16_len,
@@ -559,7 +567,15 @@
 	/* Fetch the object. */
 	COLLATOR_METHOD_FETCH_OBJECT;

+	if (!co || !co->ucoll) {
+		intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+		intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+			"Object not initialized", 0 TSRMLS_CC );
+		php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");

+		RETURN_FALSE;
+	}
+
 	/*
 	 * Compare given strings (converting them to UTF-16 first).
 	 */
@@ -579,10 +595,6 @@
 		RETURN_FALSE;
 	}

-	if (!co || !co->ucoll) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
-	}
-
 	key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0);
 	if(!key_len) {
 		efree( ustr );

Modified: php/php-src/trunk/ext/intl/tests/bug60192-compare.phpt
===================================================================
--- php/php-src/trunk/ext/intl/tests/bug60192-compare.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/tests/bug60192-compare.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -6,7 +6,6 @@
 ?>
 --FILE--
 <?php
-
 class Collator2 extends Collator{
 	public function __construct() {
 		// ommitting parent::__construct($someLocale);
@@ -14,7 +13,7 @@
 }

 $c = new Collator2();
-$c->compare('h', 'H');
+$a = $c->compare('h', 'H');
 --EXPECTF--

-Fatal error: Collator::compare(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::compare(): Object not initialized in %s on line %d

Modified: php/php-src/trunk/ext/intl/tests/bug60192-getlocale.phpt
===================================================================
--- php/php-src/trunk/ext/intl/tests/bug60192-getlocale.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/tests/bug60192-getlocale.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -17,4 +17,4 @@
 $c->getLocale(Locale::ACTUAL_LOCALE);
 --EXPECTF--

-Fatal error: Collator::getLocale(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getLocale(): Object not initialized in %s on line %d

Modified: php/php-src/trunk/ext/intl/tests/bug60192-getsortkey.phpt
===================================================================
--- php/php-src/trunk/ext/intl/tests/bug60192-getsortkey.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/tests/bug60192-getsortkey.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -17,4 +17,4 @@
 $c->getSortKey('h');
 --EXPECTF--

-Fatal error: Collator::getSortKey(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getSortKey(): Object not initialized in %s on line %d

Modified: php/php-src/trunk/ext/intl/tests/bug60192-sort.phpt
===================================================================
--- php/php-src/trunk/ext/intl/tests/bug60192-sort.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/tests/bug60192-sort.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -18,4 +18,4 @@
 $c->sort($a);
 --EXPECTF--

-Fatal error: Collator::sort(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sort(): Object not initialized in %s on line %d

Modified: php/php-src/trunk/ext/intl/tests/bug60192-sortwithsortkeys.phpt
===================================================================
--- php/php-src/trunk/ext/intl/tests/bug60192-sortwithsortkeys.phpt	2011-11-03 15:47:19 UTC (rev 318743)
+++ php/php-src/trunk/ext/intl/tests/bug60192-sortwithsortkeys.phpt	2011-11-03 16:20:11 UTC (rev 318744)
@@ -18,4 +18,4 @@
 $c->sortWithSortKeys($a);
 --EXPECTF--

-Fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to