|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-23 07:30 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2021-07-23 07:30 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 16:00:02 2025 UTC |
Description: ------------ When OPcache is not present, default_static_members_table gets written to directly instead of being copied. I'm not sure why this is; at best it seems like a premature optimisation, especially considering that OPcache should be used in the 99% case. This problem has plagued ext-pthreads and other threading extensions for many years (since even before PHP 7.0), creating inconsistencies of behaviour when OPcache is used, vs when it is not. This can finally be seen in userland in PHP 8.0 with the script below, which demonstrates the problem using reflection. Side note: A similar problem/inconsistency also exists with function static_variables, but these can't be inspected using reflection, since PHP doesn't offer any reflection API to see the default values of static variables. (This is primarily a problem for ext-pthreads class copying.) Test script: --------------- <?php class Statics{ public static $staticVar = 1; } Statics::$staticVar = 2; $reflect = new \ReflectionClass(Statics::class); $prop = $reflect->getProperty("staticVar"); var_dump($prop->getDefaultValue()); Expected result: ---------------- int(1) Actual result: -------------- WITH OPcache: int(1) WITHOUT OPcache: int(2)