summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2006-06-05 13:58:52 +0000
committerZeev Suraski <zeev@php.net>2006-06-05 13:58:52 +0000
commit51d495850a74177f38207b1e39c3365b77a5a7d6 (patch)
treeb7410f4625f924023eedd812142e797b5591fe3e /Zend/zend_operators.c
parent163f0da75a820a52fa06bad1e420df1cc644bbd3 (diff)
downloadphp-git-51d495850a74177f38207b1e39c3365b77a5a7d6.tar.gz
Restore ZE1 compatibility mode (Zend Engine part - the modules patches
will follow later today)
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r--Zend/zend_operators.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 65a224840a..37f412fe75 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -340,7 +340,14 @@ ZEND_API void convert_to_long_base(zval *op, int base)
return;
}
- zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name);
+ if (EG(ze1_compatibility_mode)) {
+ HashTable *ht = Z_OBJPROP_P(op);
+ if (ht) {
+ retval = (zend_hash_num_elements(ht)?1:0);
+ }
+ } else {
+ 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;
@@ -399,7 +406,15 @@ ZEND_API void convert_to_double(zval *op)
return;
}
- zend_error(E_NOTICE, "Object of class %s could not be converted to double", Z_OBJCE_P(op)->name);
+ if (EG(ze1_compatibility_mode)) {
+ HashTable *ht = Z_OBJPROP_P(op);
+ if (ht) {
+ retval = (zend_hash_num_elements(ht)?1.0:0.0);
+ }
+ } else {
+ zend_error(E_NOTICE, "Object of class %s could not be converted to double", Z_OBJCE_P(op)->name);
+ }
+
zval_dtor(op);
ZVAL_DOUBLE(op, retval);
break;
@@ -486,6 +501,13 @@ ZEND_API void convert_to_boolean(zval *op)
return;
}
+ if (EG(ze1_compatibility_mode)) {
+ HashTable *ht = Z_OBJPROP_P(op);
+ if (ht) {
+ retval = (zend_hash_num_elements(ht)?1:0);
+ }
+ }
+
zval_dtor(op);
ZVAL_BOOL(op, retval);
break;
@@ -1452,7 +1474,15 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
break;
case IS_OBJECT:
if (Z_OBJ_HT_P(op1) == Z_OBJ_HT_P(op2)) {
- result->value.lval = (Z_OBJ_HANDLE_P(op1) == Z_OBJ_HANDLE_P(op2));
+ if (EG(ze1_compatibility_mode)) {
+ zend_compare_objects(result, op1, op2 TSRMLS_CC);
+ /* comparison returns 0 in case of equality and
+ * 1 in case of ineqaulity, we need to reverse it
+ */
+ result->value.lval = !result->value.lval;
+ } else {
+ result->value.lval = (Z_OBJ_HANDLE_P(op1) == Z_OBJ_HANDLE_P(op2));
+ }
} else {
result->value.lval = 0;
}