From: Dmitry Stogov Date: Fri, 14 Jan 2005 08:50:00 +0000 (+0000) Subject: Revert to old behavior of $str["str"]. ($str["str"] is equivalent of $str[0]) X-Git-Tag: php-5.0.4RC1~350 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cbe8634bbe6324305e391aecfe7db07275264969;p=php Revert to old behavior of $str["str"]. ($str["str"] is equivalent of $str[0]) --- diff --git a/Zend/tests/bug31098.phpt b/Zend/tests/bug31098.phpt index 8e6c0277f9..4347b10988 100644 --- a/Zend/tests/bug31098.phpt +++ b/Zend/tests/bug31098.phpt @@ -17,7 +17,7 @@ var_dump(isset($a{'b'})); $simpleString = "Bogus String Text"; echo isset($simpleString->wrong)?"bug\n":"ok\n"; -echo isset($simpleString["wrong"])?"bug\n":"ok\n"; +echo isset($simpleString["wrong"])?"ok\n":"bug\n"; echo isset($simpleString[-1])?"bug\n":"ok\n"; echo isset($simpleString[0])?"ok\n":"bug\n"; echo isset($simpleString["0"])?"ok\n":"bug\n"; @@ -25,18 +25,18 @@ echo isset($simpleString["16"])?"ok\n":"bug\n"; echo isset($simpleString["17"])?"bug\n":"ok\n"; echo isset($simpleString["wrong"][0])?"bug\n":"ok\n"; echo $simpleString->wrong === null?"ok\n":"bug\n"; -echo $simpleString["wrong"] === null?"ok\n":"bug\n"; +echo $simpleString["wrong"] === "B"?"ok\n":"bug\n"; echo $simpleString["0"] === "B"?"ok\n":"bug\n"; $simpleString["wrong"] = "f"; -echo $simpleString["0"] === "B"?"ok\n":"bug\n"; +echo $simpleString["0"] === "f"?"ok\n":"bug\n"; ?> --EXPECTF-- bool(false) bool(false) bool(false) bool(false) -bool(false) -bool(false) +bool(true) +bool(true) ok ok ok @@ -46,12 +46,8 @@ ok ok ok -Notice: Trying to get property of non-object in %sbug31098.php on line %d +Notice: Trying to get property of non-object in /home/dmitry/php/php5.0/Zend/tests/bug31098.php on line 24 ok - -Notice: Trying to get string index from a string in %sbug31098.php on line %d ok ok - -Notice: Trying to get string index from a string in %sbug31098.php on line %d ok diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index e8bdb902a7..7251dd323b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -967,24 +967,7 @@ static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2, offset = get_zval_ptr(op2, Ts, &EG(free_op2), BP_VAR_R); - if (Z_TYPE_P(offset) == IS_STRING) { - char *strval; - long lval; - - strval = Z_STRVAL_P(offset); - if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) { - ZVAL_LONG(&tmp, lval); - offset = &tmp; - } else { - if (type != BP_VAR_IS) { - zend_error(E_NOTICE, "Trying to get string index from a string"); - } - *retval = &EG(error_zval_ptr);; - SELECTIVE_PZVAL_LOCK(**retval, result); - FREE_OP(Ts, op2, EG(free_op2)); - return; - } - } else if (offset->type != IS_LONG) { + if (offset->type != IS_LONG) { tmp = *offset; zval_copy_ctor(&tmp); convert_to_long(&tmp); @@ -4052,16 +4035,7 @@ static int zend_isset_isempty_dim_prop_obj_handler(int prop_dim, ZEND_OPCODE_HAN } else if ((*container)->type == IS_STRING && !prop_dim) { /* string offsets */ zval tmp; - if (Z_TYPE_P(offset) == IS_STRING) { - char *strval; - long lval; - - strval = Z_STRVAL_P(offset); - if (is_numeric_string(strval, Z_STRLEN_P(offset), &lval, NULL, 0) == IS_LONG) { - ZVAL_LONG(&tmp, lval); - offset = &tmp; - } - } else if (offset->type != IS_LONG) { + if (offset->type != IS_LONG) { tmp = *offset; zval_copy_ctor(&tmp); convert_to_long(&tmp);