Bug #74450 [NEW]: Fetching constant value triggers inconsistent behaviour

From: Date: Sat, 15 Apr 2017 21:27:53 +0000
Subject: Bug #74450 [NEW]: Fetching constant value triggers inconsistent behaviour
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208583@lists.php.net to get a copy of this message
From:             diego dot bindart at gmail dot com
Operating system: Linux Mint 18
PHP version:      7.0.18
Package:          Apache2 related
Bug Type:         Bug
Bug description:Fetching constant value triggers inconsistent behaviour

Description:
------------
I define a constant as case-insenstive and then define a capitalization
variation of the same constant. In between defines I echo the value of
the constant *using the case-sensitive capitalization*.

In the CLI it works as expected, but testing in the apache server gives
me the right anser only once, and then a different answers on succesive
page reloads. The same happens if instead of echoing I assign the
constant value to a variable (e.g. $var = SOME_CONST).

Tested on Chrome, Opera and Firefox, using Apache 2.4.18 Ubuntu.

Steps to reproduce:
* execute the code below, as given, in a web server. You should get (as
expected): 12
* reload the page (might need to do this several times) and you get
instead: 11

----------------
Other things to note that I tested:

* it works as expected in the command line
* if you don't echo SOME_CONST before defining the case-sensitive
variation, it works as expected
* if you echo SOME_const (or any other capitalization variation) there's
no bug either
* sometimes it needs one reload and sometimes many (never more than 3 or
4, though)
* after you get the bug, comment the first echo and you'll get the right
result again; remove the comment and you get the bug again after few
reloads
* if I print the defined constants I see both constants with the right
values (namely 1 and 2)

Test script:
---------------
define('sOmE_CoNsT', 1, true);
echo SOME_CONST; // Prints 1

define('SOME_CONST', 2);
echo SOME_CONST; // Prints 2

Expected result:
----------------
Consistently prints "12" on successive page loads

Actual result:
--------------
Prints "12" the first few times, then "11" on successive page reloads

-- 
Edit bug report at https://bugs.php.net/bug.php?id=74450&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74450&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74450&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74450&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74450&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74450&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74450&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74450&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74450&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74450&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74450&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74450&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74450&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74450&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74450&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74450&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74450&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74450&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74450&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74450&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74450&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#208583) next »