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

From: Date: Mon, 12 Sep 2005 11:48:57 +0000
Subject: cvs: ZendEngine2(PHP_5_1) / 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-4114@lists.php.net to get a copy of this message
dmitry Mon Sep 12 07:48:57 2005 EDT Added files: (Branch: PHP_5_1) /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.2027.2.56&r2=1.2027.2.57&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.56 php-src/NEWS:1.2027.2.57 --- php-src/NEWS:1.2027.2.56 Mon Sep 12 04:23:59 2005 +++ php-src/NEWS Mon Sep 12 07:48:53 2005 @@ -46,6 +46,8 @@ (Dmitry) - Fixed bug #34257 (lib64 not handled correctly in ming extension). (Marcus) - Fixed bug #34221 (Compiling xmlrpc as shared fails other parts). (Jani) +- Fixed bug #34199 (if($obj)/if(!$obj) inconsistency because of cast handler). + (Dmitry, Alex) - Fixed bug #34191 (ob_gzhandler does not enforce trailing \0). (Ilia) - Fixed bug #34156 (memory usage remains elevated after memory limit is reached). (Ilia) http://cvs.php.net/diff.php/ZendEngine2/zend_execute.h?r1=1.84.2.1&r2=1.84.2.2&ty=u Index: ZendEngine2/zend_execute.h diff -u ZendEngine2/zend_execute.h:1.84.2.1 ZendEngine2/zend_execute.h:1.84.2.2 --- ZendEngine2/zend_execute.h:1.84.2.1 Fri Sep 9 02:48:48 2005 +++ ZendEngine2/zend_execute.h Mon Sep 12 07:48:56 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.h,v 1.84.2.1 2005/09/09 06:48:48 dmitry Exp $ */ +/* $Id: zend_execute.h,v 1.84.2.2 2005/09/12 11:48:56 dmitry Exp $ */ #ifndef ZEND_EXECUTE_H #define ZEND_EXECUTE_H @@ -99,6 +99,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.208&r2=1.208.2.1&ty=u Index: ZendEngine2/zend_operators.c diff -u ZendEngine2/zend_operators.c:1.208 ZendEngine2/zend_operators.c:1.208.2.1 --- ZendEngine2/zend_operators.c:1.208 Fri Aug 5 05:02:14 2005 +++ ZendEngine2/zend_operators.c Mon Sep 12 07:48:56 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_operators.c,v 1.208 2005/08/05 09:02:14 dmitry Exp $ */ +/* $Id: zend_operators.c,v 1.208.2.1 2005/09/12 11:48:56 dmitry Exp $ */ #include <ctype.h> @@ -482,7 +482,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 (#4114) next »