Mantis - Quercus
Viewing Issue Advanced Details
1140 major always 05-22-06 14:11 05-22-06 16:19
koreth  
ferg  
normal  
closed 3.0.20  
fixed  
none    
none 3.0.20  
0001140: Defined constants aren't evaluated
PHP:

<?php
define(FOO, 1);
print FOO;
?>

Zend PHP prints "1". Quercus prints "FOO".
060522 snapshot

Notes
(0001169)
koreth   
05-22-06 14:36   
This patch seems to fix it:

--- modules/quercus/src/com/caucho/quercus/env/Env.java- 2006-05-22 14:34:55.000000000 -0700
+++ modules/quercus/src/com/caucho/quercus/env/Env.java 2006-05-22 14:35:06.000000000 -0700
@@ -1712,14 +1712,14 @@
   {
     Value oldValue = _constMap.get(name);
 
- if (oldValue != null)
- return oldValue;
-
     _constMap.put(name, value);
 
     if (isCaseInsensitive)
       _lowerConstMap.put(name.toLowerCase(), value);
 
+ if (oldValue != null)
+ return oldValue;
+
     return value;
   }
(0001175)
ferg   
05-22-06 16:19   
php/0505

The patch isn't quite right because new define() does not override the old one. The bug is in the getConstant() which is defining FOO as "FOO" if FOO isn't defined already, i.e.

define("FOO", 1); would work but

define(FOO, 1); was treated as:

define("FOO", "FOO");
define("FOO", 1);