Bug #67880 [Asn->Csd]: Class const with calculation.
| From: | dmitry@php.net | Date: | Fri, 07 Nov 2014 08:07:35 +0000 |
| Subject: | Bug #67880 [Asn->Csd]: Class const with calculation. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188497@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67880&edit=1
ID: 67880
Updated by: dmitry@php.net
Reported by: tux at krageroby dot no
Summary: Class const with calculation.
-Status: Assigned
+Status: Closed
Type: Bug
Package: opcache
Operating System: xUbuntu 14.04
PHP Version: 5.6.0
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
It seems to be fixed already.
Previous Comments:
------------------------------------------------------------------------
[2014-09-01 07:34:21] phpwnd at gmail dot com
I see similar behaviour on PHP 5.6.0 but without a crash. The const value becomes UNKNOWN (gettype()
returns "unknown type") when accessed from within the class. Accessing it from *outside*
the class works correctly. Here's my reproduce code:
class foo
{
const one = 1;
const two = 1 + self::one;
public static function dump() { var_dump(foo::two); }
}
var_dump(foo::two);
foo::dump();
Once the script is cached by Opcache, its output becomes:
int(2)
UNKNOWN:0
It doesn't crash, so I have no stack trace to attach.
------------------------------------------------------------------------
[2014-08-28 19:59:39] tux at krageroby dot no
Tested again without opcache on, and the error is gone. Pretty sure it is opcache related. I have
not been successful to create a backtrace.
------------------------------------------------------------------------
[2014-08-21 17:25:57] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
------------------------------------------------------------------------
[2014-08-21 12:20:54] tux at krageroby dot no
Description:
------------
Declaring constants that does calculations like in the sample below only works sometimes.
One simple example posted below, I have also some heavier code (I could not reproduce in a small
example, but I would think the problem is covered by the other example) that works the first time
loaded, and then produce the message: Fatal error: Unsupported operand types in ⦠until the
.php file is changed in any way. After the php file is changed, the code runs once before crashing
again.
Test script:
---------------
class Test
{
const ONE = 1;
const TWO = 2;
const THREE = self::ONE + self::TWO;
public function run ()
{
return self::THREE;
}
}
$test = new Test();
echo $test->run();
Expected result:
----------------
3
Actual result:
--------------
Works in cli mode, but apache responds with: 500 internal server error
[Thu Aug 21 13:07:34.283310 2014] [mpm_itk:error] [pid 5184] child died with signal 11
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67880&edit=1