php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #62977
Patch bug62977.patch revision 2012-08-30 15:52 UTC by laruence@php.net

Patch bug62977.patch for Date/time related Bug #62977

Patch version 2012-08-30 15:52 UTC

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

Developer: laruence@php.net

diff --git a/ext/standard/array.c b/ext/standard/array.c
index 94c5e7e..3c8c5df 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -396,6 +396,28 @@ static int php_array_data_compare(const void *a, const void *b TSRMLS_DC) /* {{{
 }
 /* }}} */
 
+static int php_array_data_sort_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */ {
+	Bucket *f;
+	Bucket *s;
+	zval *first;
+	zval *second;
+
+	f = *((Bucket **) a);
+	s = *((Bucket **) b);
+
+	first = *((zval **) f->pData);
+	second = *((zval **) s->pData);
+
+	if (Z_TYPE_P(first) == IS_OBJECT && Z_TYPE_P(second) == IS_OBJECT) {
+		if (Z_OBJCE_P(first) == Z_OBJCE_P(second)) {
+			return 0;
+		}
+	}
+
+	return php_array_data_compare(a, b TSRMLS_CC);
+}
+/* }}} */
+
 static int php_array_reverse_data_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */
 {
 	return php_array_data_compare(a, b TSRMLS_CC) * -1;
@@ -2810,7 +2832,7 @@ PHP_FUNCTION(array_unique)
 		arTmp[i].i = i;
 	}
 	arTmp[i].b = NULL;
-	zend_qsort((void *) arTmp, i, sizeof(struct bucketindex), php_array_data_compare TSRMLS_CC);
+	zend_qsort((void *) arTmp, i, sizeof(struct bucketindex), php_array_data_sort_compare TSRMLS_CC);
 
 	/* go through the sorted array and delete duplicates from the copy */
 	lastkept = arTmp;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC