From: Dmitry Stogov Date: Fri, 5 Aug 2005 09:02:14 +0000 (+0000) Subject: Fixed bug #33999 (object remains object when cast to int) X-Git-Tag: RELEASE_2_0_0~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c10d6d3c899695d1704980b0b0ff3d7f3868cf1e;p=php Fixed bug #33999 (object remains object when cast to int) --- diff --git a/NEWS b/NEWS index dbb772a085..412feb99e3 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2005, PHP 5.1 +- Fixed bug #33999 (object remains object when cast to int). (Dmitry) - Fixed bug #33989 (extract($GLOBALS,EXTR_REFS) crashes PHP). (Dmitry) - Fixed bug #33967 (misuse of Exception constructor doesn't display errorfile). (Jani) diff --git a/Zend/tests/bug33999.phpt b/Zend/tests/bug33999.phpt new file mode 100755 index 0000000000..1946280712 --- /dev/null +++ b/Zend/tests/bug33999.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #33999 (object remains object when cast to int) +--INI-- +error_reporting=4095 +--FILE-- + +--EXPECTF-- +object(Foo)#1 (1) { + ["bar"]=> + string(3) "bat" +} + +Notice: Object of class Foo could not be converted to int in %sbug33999.php on line 9 +int(1) + +Notice: Object of class Foo could not be converted to double in %sbug33999.php on line 12 +float(1) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 1590e35a04..509f9e2315 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -338,13 +338,12 @@ ZEND_API void convert_to_long_base(zval *op, int base) if (ht) { retval = (zend_hash_num_elements(ht)?1:0); } - zval_dtor(op); - ZVAL_LONG(op, retval); - return; } else { - /* we cannot convert it to long */ - return; + zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name); } + zval_dtor(op); + ZVAL_LONG(op, retval); + return; } default: zend_error(E_WARNING, "Cannot convert to ordinal value"); @@ -1319,7 +1318,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) zendi_smart_strcmp(result, op1, op2); COMPARE_RETURN_AND_FREE(SUCCESS); } - + if (op1->type == IS_BOOL || op2->type == IS_BOOL || op1->type == IS_NULL || op2->type == IS_NULL) { zendi_convert_to_boolean(op1, op1_copy, result);