Commit:    df97c3aa0d331be668bd5d8f27fff96d4e3ac1d7
Author:    Dmitry Stogov <dmi...@zend.com>         Wed, 5 Dec 2012 17:58:36 
+0400
Parents:   881416cda670a7ddb94db11a41d4929425da7d61
Branches:  PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=df97c3aa0d331be668bd5d8f27fff96d4e3ac1d7

Log:
Use get_gc instead of hacks of get_properties

Changed paths:
  M  ext/date/php_date.c
  M  ext/simplexml/simplexml.c
  M  ext/spl/spl_observer.c


Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index b87dfcb..b588227 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -563,7 +563,9 @@ static zend_object_value date_object_clone_interval(zval 
*this_ptr TSRMLS_DC);
 static zend_object_value date_object_clone_period(zval *this_ptr TSRMLS_DC);
 
 static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC);
+static HashTable *date_object_get_gc(zval *object, zval ***table, int *n 
TSRMLS_DC);
 static HashTable *date_object_get_properties(zval *object TSRMLS_DC);
+static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int 
*n TSRMLS_DC);
 static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC);
 
 zval *date_interval_read_property(zval *object, zval *member, int type, const 
zend_literal *key TSRMLS_DC);
@@ -1887,6 +1889,7 @@ static void date_register_classes(TSRMLS_D)
        date_object_handlers_date.clone_obj = date_object_clone_date;
        date_object_handlers_date.compare_objects = date_object_compare_date;
        date_object_handlers_date.get_properties = date_object_get_properties;
+       date_object_handlers_date.get_gc = date_object_get_gc;
 
 #define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \
        zend_declare_class_constant_stringl(date_ce_date, const_name, 
sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC);
@@ -1937,6 +1940,7 @@ static void date_register_classes(TSRMLS_D)
        date_object_handlers_interval.write_property = 
date_interval_write_property;
        date_object_handlers_interval.get_properties = 
date_object_get_properties_interval;
        date_object_handlers_interval.get_property_ptr_ptr = NULL;
+       date_object_handlers_interval.get_gc = date_object_get_gc_interval;
 
        INIT_CLASS_ENTRY(ce_period, "DatePeriod", date_funcs_period);
        ce_period.create_object = date_object_new_period;
@@ -2023,6 +2027,13 @@ static int date_object_compare_date(zval *d1, zval *d2 
TSRMLS_DC)
        return 1;
 }
 
+static HashTable *date_object_get_gc(zval *object, zval ***table, int *n 
TSRMLS_DC)
+{
+       *table = NULL;
+       *n = 0;
+       return zend_std_get_properties(object TSRMLS_CC);
+}
+
 static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
 {
        HashTable *props;
@@ -2034,7 +2045,7 @@ static HashTable *date_object_get_properties(zval *object 
TSRMLS_DC)
 
        props = zend_std_get_properties(object TSRMLS_CC);
 
-       if (!dateobj->time || GC_G(gc_active)) {
+       if (!dateobj->time) {
                return props;
        }
 
@@ -2168,6 +2179,14 @@ static zend_object_value date_object_clone_interval(zval 
*this_ptr TSRMLS_DC)
        return new_ov;
 }
 
+static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int 
*n TSRMLS_DC)
+{
+
+       *table = NULL;
+       *n = 0;
+       return zend_std_get_properties(object TSRMLS_CC);
+}
+
 static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
 {
        HashTable *props;
@@ -2179,7 +2198,7 @@ static HashTable 
*date_object_get_properties_interval(zval *object TSRMLS_DC)
 
        props = zend_std_get_properties(object TSRMLS_CC);
 
-       if (!intervalobj->initialized || GC_G(gc_active)) {
+       if (!intervalobj->initialized) {
                return props;
        }
 
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 5514f0f..b510786 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1081,15 +1081,9 @@ static HashTable * sxe_get_prop_hash(zval *object, int 
is_debug TSRMLS_DC) /* {{
                zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0);
        }
        else if (sxe->properties) {
-               if (GC_G(gc_active)) {
-                       return sxe->properties;
-               }
                zend_hash_clean(sxe->properties);
                rv = sxe->properties;
        } else {
-               if (GC_G(gc_active)) {
-                       return NULL;
-               }
                ALLOC_HASHTABLE(rv);
                zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0);
                sxe->properties = rv;
@@ -1201,6 +1195,16 @@ next_iter:
 }
 /* }}} */
 
+static HashTable * sxe_get_gc(zval *object, zval ***table, int *n TSRMLS_DC) 
/* {{{ */ {
+       php_sxe_object  *sxe;
+       sxe = php_sxe_fetch_object(object TSRMLS_CC);
+       
+       *table = NULL;
+       *n = 0;
+       return sxe->properties;
+}
+/* }}} */
+
 static HashTable * sxe_get_properties(zval *object TSRMLS_DC) /* {{{ */
 {
        return sxe_get_prop_hash(object, 0 TSRMLS_CC);
@@ -1966,7 +1970,9 @@ static zend_object_handlers sxe_object_handlers = { /* 
{{{ */
        sxe_objects_compare,
        sxe_object_cast,
        sxe_count_elements,
-       sxe_get_debug_info
+       sxe_get_debug_info,
+       NULL,
+       sxe_get_gc
 };
 /* }}} */
 
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 4b8be82..60c3188 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -361,9 +361,8 @@ static HashTable* spl_object_storage_debug_info(zval *obj, 
int *is_temp TSRMLS_D
 /* }}} */
 
 /* overriden for garbage collection
- * This is very hacky, but unfortunately the garbage collector can only query 
objects for
- * dependencies through get_properties */
-static HashTable *spl_object_storage_get_properties(zval *obj TSRMLS_DC) /* 
{{{ */
+ * This is very hacky */
+static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n 
TSRMLS_DC) /* {{{ */
 {
        spl_SplObjectStorage *intern = 
(spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
        spl_SplObjectStorageElement *element;
@@ -374,14 +373,8 @@ static HashTable *spl_object_storage_get_properties(zval 
*obj TSRMLS_DC) /* {{{
 
        props = std_object_handlers.get_properties(obj TSRMLS_CC);
        
-       if (!GC_G(gc_active)) {
-               zend_hash_del(props, "\x00gcdata", sizeof("\x00gcdata"));
-               return props;
-       }
-
-       if (props->nApplyCount > 0) {
-               return props;
-       }
+       *table = NULL;
+       *n = 0;
 
        /* clean \x00gcdata, as it may be out of date */
        if (zend_hash_find(props, "\x00gcdata", sizeof("\x00gcdata"), (void**) 
&gcdata_arr_pp) == SUCCESS) {
@@ -1316,10 +1309,10 @@ PHP_MINIT_FUNCTION(spl_observer)
        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_properties  = 
spl_object_storage_get_properties;
        spl_handler_SplObjectStorage.get_debug_info  = 
spl_object_storage_debug_info;
        spl_handler_SplObjectStorage.compare_objects = 
spl_object_storage_compare_objects;
        spl_handler_SplObjectStorage.clone_obj       = spl_object_storage_clone;
+       spl_handler_SplObjectStorage.get_gc          = 
spl_object_storage_get_gc;
 
        REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Countable);
        REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Iterator);


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

Reply via email to