cvs: ZendEngine2 / zend_execute.h zend_operators.c /tests bug34199.phpt php-src NEWS

From: Date: Mon, 12 Sep 2005 11:48:29 +0000
Subject: cvs: ZendEngine2 / zend_execute.h zend_operators.c /tests bug34199.phpt php-src NEWS
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4113@lists.php.net to get a copy of this message
dmitry Mon Sep 12 07:48:29 2005 EDT Added files: /ZendEngine2/tests bug34199.phpt Modified files: /php-src NEWS /ZendEngine2 zend_execute.h zend_operators.c Log: Fixed bug #34199 (if($obj)/if(!$obj) inconsistency) http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2059&r2=1.2060&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2059 php-src/NEWS:1.2060 --- php-src/NEWS:1.2059 Mon Sep 12 04:23:43 2005 +++ php-src/NEWS Mon Sep 12 07:48:26 2005 @@ -25,6 +25,8 @@ (Dmitry) - Fixed bug #34260 (Segfault with callbacks (array_map) + overloading). (Dmitry) +- Fixed bug #34199 (if($obj)/if(!$obj) inconsistency because of cast handler). + (Dmitry, Alex) - Fixed bug #34137 (assigning array element by reference causes binary mess). (Dmitry) - Fixed bug #33957 (gmdate('W')/date('W') sometimes returns wrong week number). http://cvs.php.net/diff.php/ZendEngine2/zend_execute.h?r1=1.86&r2=1.87&ty=u Index: ZendEngine2/zend_execute.h diff -u ZendEngine2/zend_execute.h:1.86 ZendEngine2/zend_execute.h:1.87 --- ZendEngine2/zend_execute.h:1.86 Tue Aug 23 03:23:30 2005 +++ ZendEngine2/zend_execute.h Mon Sep 12 07:48:27 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.h,v 1.86 2005/08/23 07:23:30 dmitry Exp $ */ +/* $Id: zend_execute.h,v 1.87 2005/09/12 11:48:27 dmitry Exp $ */ #ifndef ZEND_EXECUTE_H #define ZEND_EXECUTE_H @@ -111,6 +111,24 @@ case IS_OBJECT: if(IS_ZEND_STD_OBJECT(*op)) { TSRMLS_FETCH(); + + if (Z_OBJ_HT_P(op)->cast_object) { + zval tmp; + if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_BOOL, 1 TSRMLS_CC) == SUCCESS) { + result = Z_LVAL(tmp); + break; + } + } else if (Z_OBJ_HT_P(op)->get) { + zval *tmp = Z_OBJ_HT_P(op)->get(op TSRMLS_CC); + if(Z_TYPE_P(tmp) != IS_OBJECT) { + /* for safety - avoid loop */ + convert_to_boolean(tmp); + result = Z_LVAL_P(tmp); + zval_ptr_dtor(&tmp); + break; + } + } + if(EG(ze1_compatibility_mode)) { result = (zend_hash_num_elements(Z_OBJPROP_P(op))?1:0); } else { http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.220&r2=1.221&ty=u Index: ZendEngine2/zend_operators.c diff -u ZendEngine2/zend_operators.c:1.220 ZendEngine2/zend_operators.c:1.221 --- ZendEngine2/zend_operators.c:1.220 Mon Sep 12 05:53:20 2005 +++ ZendEngine2/zend_operators.c Mon Sep 12 07:48:27 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_operators.c,v 1.220 2005/09/12 09:53:20 derick Exp $ */ +/* $Id: zend_operators.c,v 1.221 2005/09/12 11:48:27 dmitry Exp $ */ #include <ctype.h> @@ -568,7 +568,7 @@ zend_bool retval = 1; TSRMLS_FETCH(); - convert_object_to_type(op, IS_BOOL, convert_to_double); + convert_object_to_type(op, IS_BOOL, convert_to_boolean); if (op->type == IS_BOOL) { return; http://cvs.php.net/co.php/ZendEngine2/tests/bug34199.phpt?r=1.1&p=1 Index: ZendEngine2/tests/bug34199.phpt +++ ZendEngine2/tests/bug34199.phpt --TEST-- Bug #34199 (if($obj)/if(!$obj) inconsistency because of cast handler) --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- <?php $xml = "<root></root>"; $xml = simplexml_load_string($xml); $kids = $xml->children(); var_dump((bool)$kids); if($kids) echo "bug\n"; else echo "ok\n"; if(!$kids) echo "ok\n"; else echo "bug\n"; ?> --EXPECT-- bool(false) ok ok

« previous php.zend-engine.cvs (#4113) next »