logo       

cvs: ZendEngine2 / zend_execute.c zend_vm_def.h: msg#00186

Subject: cvs: ZendEngine2 / zend_execute.c zend_vm_def.h
stas            Tue Jun 28 06:49:59 2005 EDT

  Modified files:              
    /ZendEngine2        zend_execute.c zend_vm_def.h 
  Log:
  fixes for non-php objects
  
  
http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.708&r2=1.709&ty=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.708 ZendEngine2/zend_execute.c:1.709
--- ZendEngine2/zend_execute.c:1.708    Thu Jun 23 04:21:03 2005
+++ ZendEngine2/zend_execute.c  Tue Jun 28 06:49:56 2005
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.c,v 1.708 2005/06/23 08:21:03 dmitry Exp $ */
+/* $Id: zend_execute.c,v 1.709 2005/06/28 10:49:56 stas Exp $ */
 
 #define ZEND_INTENSIVE_DEBUGGING 0
 
@@ -530,15 +530,19 @@
        /* separate our value if necessary */
        if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
                zval *orig_value = value;
+               char *class_name;
+               zend_uint class_name_len;
+               int dup;
                
                ALLOC_ZVAL(value);
                *value = *orig_value;
                value->is_ref = 0;
                value->refcount = 0;
+               dup = zend_get_object_classname(orig_value, &class_name, 
&class_name_len TSRMLS_CC);
                if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
-                       zend_error_noreturn(E_ERROR, "Trying to clone an 
uncloneable object of class %s",  Z_OBJCE_P(orig_value)->name);
+                       zend_error_noreturn(E_ERROR, "Trying to clone an 
uncloneable object of class %s",  class_name);
                }
-               zend_error(E_STRICT, "Implicit cloning object of class '%s' 
because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(orig_value)->name);        
    
+               zend_error(E_STRICT, "Implicit cloning object of class '%s' 
because of 'zend.ze1_compatibility_mode'", class_name);             
                value->value.obj = Z_OBJ_HANDLER_P(orig_value, 
clone_obj)(orig_value TSRMLS_CC);
        } else if (value_op->op_type == IS_TMP_VAR) {
                zval *orig_value = value;
@@ -547,6 +551,9 @@
                *value = *orig_value;
                value->is_ref = 0;
                value->refcount = 0;
+               if(dup) {
+                       efree(class_name);
+               }
        } else if (value_op->op_type == IS_CONST) {
                zval *orig_value = value;
 
@@ -684,8 +691,14 @@
        }
        
        if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
+               char *class_name;
+               zend_uint class_name_len;
+               int dup;
+                       
+               dup = zend_get_object_classname(value, &class_name, 
&class_name_len TSRMLS_CC);
+ 
                if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
-                       zend_error_noreturn(E_ERROR, "Trying to clone an 
uncloneable object of class %s",  Z_OBJCE_P(value)->name);
+                       zend_error_noreturn(E_ERROR, "Trying to clone an 
uncloneable object of class %s",  class_name);
                } else if (PZVAL_IS_REF(variable_ptr)) {
                        if (variable_ptr != value) {
                                zend_uint refcount = variable_ptr->refcount;
@@ -698,7 +711,7 @@
                                *variable_ptr = *value;
                                variable_ptr->refcount = refcount;
                                variable_ptr->is_ref = 1;
-                               zend_error(E_STRICT, "Implicit cloning object 
of class '%s' because of 'zend.ze1_compatibility_mode'", 
Z_OBJCE_P(value)->name);
+                               zend_error(E_STRICT, "Implicit cloning object 
of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
                                variable_ptr->value.obj = 
Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
                                if (type != IS_TMP_VAR) {
                                        value->refcount--;
@@ -717,11 +730,14 @@
                                }
                                *variable_ptr = *value;
                                INIT_PZVAL(variable_ptr);
-                               zend_error(E_STRICT, "Implicit cloning object 
of class '%s' because of 'zend.ze1_compatibility_mode'", 
Z_OBJCE_P(value)->name);
+                               zend_error(E_STRICT, "Implicit cloning object 
of class '%s' because of 'zend.ze1_compatibility_mode'", class_name);
                                variable_ptr->value.obj = 
Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
                                zval_ptr_dtor(&value);
                        }
                }
+               if (dup) {
+                       efree(class_name);
+               }
        } else if (PZVAL_IS_REF(variable_ptr)) {
                if (variable_ptr!=value) {
                        zend_uint refcount = variable_ptr->refcount;
@@ -815,17 +831,26 @@
        zval *variable_ptr = *variable_ptr_ptr;
 
        if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
-               if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
-                       zend_error_noreturn(E_ERROR, "Trying to clone an 
uncloneable object of class %s",  Z_OBJCE_P(value)->name);
+               char *class_name;
+               zend_uint class_name_len;
+               int dup;
+
+               dup = zend_get_object_classname(value, &class_name, 
&class_name_len TSRMLS_CC);
+               
+               if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
+                       zend_error_noreturn(E_ERROR, "Trying to clone an 
uncloneable object of class %s",  class_name);
                } else {
                        variable_ptr->refcount--;
                        ALLOC_ZVAL(variable_ptr);
                        *variable_ptr_ptr = variable_ptr;
                        *variable_ptr = *value;
                        INIT_PZVAL(variable_ptr);
-                       zend_error(E_STRICT, "Implicit cloning object of class 
'%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(value)->name);
+                       zend_error(E_STRICT, "Implicit cloning object of class 
'%s' because of 'zend.ze1_compatibility_mode'", class_name);
                        variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, 
clone_obj)(value TSRMLS_CC);
                }
+               if (dup) {
+                       efree(class_name);
+               }
        } else {
                variable_ptr->refcount--;
                *variable_ptr_ptr = value;
http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.47&r2=1.48&ty=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.47 ZendEngine2/zend_vm_def.h:1.48
--- ZendEngine2/zend_vm_def.h:1.47      Mon Jun 27 02:15:34 2005
+++ ZendEngine2/zend_vm_def.h   Tue Jun 28 06:49:56 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_vm_def.h,v 1.47 2005/06/27 06:15:34 dmitry Exp $ */
+/* $Id: zend_vm_def.h,v 1.48 2005/06/28 10:49:56 stas Exp $ */
 
 /* If you change this file, please regenerate the zend_vm_execute.h and
  * zend_vm_opcodes.h files by running:
@@ -2014,15 +2014,22 @@
 
                if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == 
IS_OBJECT) {
                        zval *ret;
+                       char *class_name;
+                       zend_uint class_name_len;
+                       int dup;
 
                        ALLOC_ZVAL(ret);
                        INIT_PZVAL_COPY(ret, retval_ptr);
+                       dup = zend_get_object_classname(orig_value, 
&class_name, &class_name_len TSRMLS_CC);
                        if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
-                               zend_error_noreturn(E_ERROR, "Trying to clone 
an uncloneable object of class %s",  Z_OBJCE_P(retval_ptr)->name);
+                               zend_error_noreturn(E_ERROR, "Trying to clone 
an uncloneable object of class %s",  class_name);
                        }
-                       zend_error(E_STRICT, "Implicit cloning object of class 
'%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name);
+                       zend_error(E_STRICT, "Implicit cloning object of class 
'%s' because of 'zend.ze1_compatibility_mode'", class_name);
                        ret->value.obj = 
Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
                        *EG(return_value_ptr_ptr) = ret;
+                       if (dup) {
+                               efree(class_name);
+                       }
                } else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */
                        if (EG(active_op_array)->return_reference == 
ZEND_RETURN_REF ||
                            (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 
0)) {
@@ -2948,6 +2955,12 @@
                if (array_ptr_ptr == NULL) {
                        ALLOC_INIT_ZVAL(array_ptr);
                } else if (Z_TYPE_PP(array_ptr_ptr) == IS_OBJECT) {
+                       if(Z_OBJ_HT_PP(array_ptr_ptr)->get_class_entry == NULL) 
{
+                               zend_error(E_WARNING, "foreach() can not 
iterate over objects without PHP class");
+                               
ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num);
+                               ZEND_VM_CONTINUE_JMP();
+                       }
+                       
                        ce = Z_OBJCE_PP(array_ptr_ptr);
                        if (!ce || ce->get_iterator == NULL) {
                                SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);
@@ -3509,7 +3522,7 @@
        zval *expr = GET_OP1_ZVAL_PTR(BP_VAR_R);
        zend_bool result;
 
-       if (Z_TYPE_P(expr) == IS_OBJECT) {
+       if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->get_class_entry) {
                result = instanceof_function(Z_OBJCE_P(expr), 
EX_T(opline->op2.u.var).class_entry TSRMLS_CC);
        } else {
                result = 0;

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




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe