Bug #74576 [NEW]: opcache do not update class constant after uopz_redefine

From: Date: Fri, 12 May 2017 05:47:27 +0000
Subject: Bug #74576 [NEW]: opcache do not update class constant after uopz_redefine
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209079@lists.php.net to get a copy of this message
From:             kejinjin at gmail dot com
Operating system: CentOS7x64
PHP version:      7.1.5
Package:          opcache
Bug Type:         Bug
Bug description:opcache do not update class constant after uopz_redefine

Description:
------------
I use uopz_redefine to redefine class constants
(uopz called zend_declare_class_constant)

when opcache is enabled, I cannot get the new class constant through
Foo::BAR.

Test script:
---------------
<?php

class Foo
{
	const BAR = '123';
}

var_dump(Foo::BAR);// A1: try to comment this

(function () {
	var_dump(Foo::BAR);	// B1: try to comment this
	uopz_redefine('Foo', 'BAR', '456');
	var_dump(Foo::BAR);	// B2: compare
})();

(function () {
	var_dump(Foo::BAR);	// new scope
})();

var_dump((new ReflectionClass('Foo'))->getConstant('BAR'));	// also OK

var_dump(Foo::BAR);	// A2: compare


Expected result:
----------------
'123'
'123'
'456'
'456'
'456'
'456'

Actual result:
--------------
'123'
'123'
'123' (it is '456' if line B1 is commented)
'456'
'456'
'123' (it is '456' if line A1 is commented)

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



Thread (8 messages)

« previous php.bugs (#209079) next »