ID: 31098
Comment by: jkkn at jkkn dot dk
Reported By: jyounger at caedic dot com
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Slackare Linux Kernel 2.4.26
PHP Version: 5.0.3
New Comment:
I am using PEAR::DB which was the main reason I wrote the patch. The
supplied patch should solve all problems with regards to PEAR::DB.
Matthew, what do you experience while using the patch?
Previous Comments:
------------------------------------------------------------------------
[2004-12-31 18:58:56] mnorth at ucsd dot edu
This bug is rather significant to anyone that uses PEAR::DB with
DB_DataObject. It effectively breaks the createTables.php script,
which in turn effectively makes useless DB_DataObject. The offending
code is the first line of function tableInfo in
(phproot)/lib/php/DB/mysql.php:
* @see DB_common::tableInfo()
*/
function tableInfo($result, $mode = null) {
if (isset($result->result)) {
/*
* Probably received a result object.
The isset() call returns true, regardless of whether $result->result is
set, and even if $result is not an object. Note, this affects ALL
(phproot)/lib/php/DB/??sql.php files, since they all contain
tableInfo() functions.
The patch supplied in this bug report doesn't solve the problem, so I
had to temporarily change function tableInfo() to call is_object()
instead of isset().
Matthew H. North
------------------------------------------------------------------------
[2004-12-20 02:10:49] jkkn at jkkn dot dk
At time patching for bug #2 9883, 'dmitry'not only applied the patch,
but also added autocasting for the offset, therefore:
isset($simpleString['nonExistentStringProperty']) is currenly
autocasted into isset($simpleString[0]) - which is true.
Same goes for empty() since this is the same function.
This patch should resolve this problem:
Index: ZendEngine2/zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.652.2.11
diff -u -r1.652.2.11 zend_execute.c
--- ZendEngine2/zend_execute.c 1 Dec 2004 14:01:58 -0000 1.652.2.11
+++ ZendEngine2/zend_execute.c 20 Dec 2004 01:08:28 -0000
@@ -4033,26 +4033,20 @@
result =
Z_OBJ_HT_P(*container)->has_dimension(*container, offset,
(opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC);
}
} else if ((*container)->type == IS_STRING) { /* string offsets
*/
- zval tmp_offset;
-
- if (Z_TYPE_P(offset) != IS_LONG) {
- tmp_offset = *offset;
- zval_copy_ctor(&tmp_offset);
- convert_to_long(&tmp_offset);
- offset = &tmp_offset;
- }
- switch (opline->extended_value) {
- case ZEND_ISSET:
- if (offset->value.lval >= 0 &&
offset->value.lval <
Z_STRLEN_PP(container)) {
- result = 1;
- }
- break;
- case ZEND_ISEMPTY:
- if (offset->value.lval >= 0 &&
offset->value.lval <
Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] !=
'0') {
- result = 1;
- }
- break;
- }
+ if (Z_TYPE_P(offset) == IS_LONG) {
+ switch (opline->extended_value) {
+ case ZEND_ISSET:
+ if (offset->value.lval >= 0 &&
offset->value.lval <
Z_STRLEN_PP(container)) {
+ result = 1;
+ }
+ break;
+ case ZEND_ISEMPTY:
+ if (offset->value.lval >= 0 &&
offset->value.lval <
Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] !=
'0') {
+ result = 1;
+ }
+ break;
+ }
+ }
}
}
Besides this the files "zend_vm_execute.h" and "zend_vm_execute.h" seem
to have been messed up in CVS HEAD at the same commit?!.
------------------------------------------------------------------------
[2004-12-17 22:19:28] ptchristendom at yahoo dot com
Empty() has the same problem.
<?php
$simpleString = "Bogus String Text";
var_dump(empty($simpleString->nonExistentStringProperty));
?>
------------------------------------------------------------------------
[2004-12-15 17:27:33] jyounger at caedic dot com
Description:
------------
isset() when run using mod_php returns a false positive when checking a
string variable for the presence of a property. isset() when run under
the cli behaves correctly and returns false. This is in PHP 5.0.3RC2.
Reproduce code:
---------------
<?php
$simpleString = "Bogus String Text";
if (isset($simpleString->nonExistentStringProperty)) {
echo "This line should not execute";
} else {
echo "This line should execute";
}
?>
Expected result:
----------------
This line should execute
Actual result:
--------------
This line should not execute
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31098&edit=1