]> granicus.if.org Git - php/commitdiff
Patch from Timm Friede for when EG(active_namespace) is NULL initially.
authorAndrei Zmievski <andrei@php.net>
Thu, 3 Apr 2003 19:05:25 +0000 (19:05 +0000)
committerAndrei Zmievski <andrei@php.net>
Thu, 3 Apr 2003 19:05:25 +0000 (19:05 +0000)
Zend/zend_API.c

index e492725c2be018caaa4f66bf79d951bb6704c2a7..eb1a5693963dee29387c1ec8d0bfdfa8efa01741 100644 (file)
@@ -1388,6 +1388,8 @@ ZEND_API zend_class_entry *zend_register_internal_class_in_ns(zend_class_entry *
 {
        zend_class_entry *register_class;
        zend_namespace *orig_namespace = NULL;
+       HashTable *orig_class_table = NULL;
+       int restore_orig = 0;
 
        if (!ns && ns_name) {
                zend_namespace **pns;
@@ -1404,16 +1406,18 @@ ZEND_API zend_class_entry *zend_register_internal_class_in_ns(zend_class_entry *
        }
 
        if (EG(active_namespace) != ns) {
+               restore_orig = 1;
                orig_namespace = EG(active_namespace);
                EG(active_namespace) = ns;
+               orig_class_table = CG(class_table);
                CG(class_table) = &ns->class_table;
        }
        register_class = zend_register_internal_class_ex(class_entry, parent_ce, NULL TSRMLS_CC);
-       if (orig_namespace) {
+       if (restore_orig) {
                EG(active_namespace) = orig_namespace;
-               CG(class_table) = &orig_namespace->class_table;
+               CG(class_table) = orig_class_table;
        }
-
+       
        return register_class;
 }