colder          Wed Jan 14 15:53:04 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/spl/tests      observer_007.phpt 

  Modified files:              
    /php-src/ext/spl    spl_observer.c 
    /php-src    NEWS 
  Log:
  MFH: Fix #47045 (Correctly compare splobjectstorages with ==)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_observer.c?r1=1.2.2.6.2.3.2.14&r2=1.2.2.6.2.3.2.15&diff_format=u
Index: php-src/ext/spl/spl_observer.c
diff -u php-src/ext/spl/spl_observer.c:1.2.2.6.2.3.2.14 
php-src/ext/spl/spl_observer.c:1.2.2.6.2.3.2.15
--- php-src/ext/spl/spl_observer.c:1.2.2.6.2.3.2.14     Wed Dec 31 11:15:44 2008
+++ php-src/ext/spl/spl_observer.c      Wed Jan 14 15:53:03 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_observer.c,v 1.2.2.6.2.3.2.14 2008/12/31 11:15:44 sebastian Exp $ 
*/
+/* $Id: spl_observer.c,v 1.2.2.6.2.3.2.15 2009/01/14 15:53:03 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -169,6 +169,31 @@
 }
 /* }}} */
 
+static int spl_object_storage_compare_info(spl_SplObjectStorageElement *e1, 
spl_SplObjectStorageElement *e2 TSRMLS_DC) /* {{{ */
+{
+       zval result;
+
+       if (compare_function(&result, e1->inf, e2->inf TSRMLS_CC) == FAILURE) {
+               return 1;
+       }
+
+       return Z_LVAL(result);
+}
+/* }}} */
+
+static int spl_object_storage_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* 
{{{ */
+{
+       zend_object *zo1 = (zend_object *)zend_object_store_get_object(o1 
TSRMLS_CC);
+       zend_object *zo2 = (zend_object *)zend_object_store_get_object(o2 
TSRMLS_CC);
+
+       if (zo1->ce != spl_ce_SplObjectStorage || zo2->ce != 
spl_ce_SplObjectStorage) {
+               return 1;
+       }
+
+       return zend_hash_compare(&((spl_SplObjectStorage *)zo1)->storage, 
&((spl_SplObjectStorage *)zo2)->storage, (compare_func_t) 
spl_object_storage_compare_info, 0 TSRMLS_CC);
+}
+/* }}} */
+
 /* {{{ spl_array_object_new */
 static zend_object_value spl_SplObjectStorage_new(zend_class_entry *class_type 
TSRMLS_DC)
 {
@@ -910,7 +935,9 @@
 
        REGISTER_SPL_STD_CLASS_EX(SplObjectStorage, spl_SplObjectStorage_new, 
spl_funcs_SplObjectStorage);
        memcpy(&spl_handler_SplObjectStorage, zend_get_std_object_handlers(), 
sizeof(zend_object_handlers));
-       spl_handler_SplObjectStorage.get_debug_info = 
spl_object_storage_debug_info;
+
+       spl_handler_SplObjectStorage.get_debug_info  = 
spl_object_storage_debug_info;
+       spl_handler_SplObjectStorage.compare_objects = 
spl_object_storage_compare_objects;
 
        REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Countable);
        REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Iterator);
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.456&r2=1.2027.2.547.2.965.2.457&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.456 
php-src/NEWS:1.2027.2.547.2.965.2.457
--- php-src/NEWS:1.2027.2.547.2.965.2.456       Wed Jan 14 13:57:41 2009
+++ php-src/NEWS        Wed Jan 14 15:53:03 2009
@@ -41,6 +41,7 @@
 - Fixed building of pdo_sqlite without sqlite3. (Scott)
 
 - Fixed bug #47050 (mysqli_poll() modifies improper variables). (Johannes)
+- Fixed bug #47045 (SplObjectStorage instances compared with ==). (Etienne)
 - Fixed bug #46979 (use with non-compound name *has* effect). (Dmitry)
 - Fixed bug #46957 (The tokenizer returns deprecated values). (Felipe)
 - Fixed bug #46944 (UTF-8 characters outside the BMP aren't encoded correctly).

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/observer_007.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/observer_007.phpt
+++ php-src/ext/spl/tests/observer_007.phpt
--TEST--
SPL: SplObjectStorage comapred with ==
--FILE--
<?php
$a = new SplObjectStorage;
$b = new SplObjectStorage;
var_dump($a == $b);
$b[$b] = 2;
var_dump($a == $b);
$a[$b] = 2;
var_dump($a == $b);
$a[$b] = 3;
var_dump($a == $b);
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
bool(true)
bool(false)
bool(true)
bool(false)
===DONE===



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to