Bug #77310 [Opn]: Variable values incorrect when Opcache enabled

From: Date: Mon, 17 Dec 2018 16:50:43 +0000
Subject: Bug #77310 [Opn]: Variable values incorrect when Opcache enabled
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218500@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77310&edit=1 ID: 77310 User updated by: taylor at laravel dot com Reported by: taylor at laravel dot com Summary: Variable values incorrect when Opcache enabled Status: Open Type: Bug Package: opcache Operating System: Multiple PHP Version: 7.3.0 Block user comment: N Private report: N New Comment: We have temporarily worked around this by referencing $this->app within the Closure which is set to the same value that $app was previously. So, Laravel >= 5.7.18 should not be affected by this; however, I am worried the bug could affect other areas of code we haven't discovered yet. Previous Comments: ------------------------------------------------------------------------ [2018-12-17 15:08:36] taylor at laravel dot com Wanted to add this has been seen on Ubuntu and Mac. ------------------------------------------------------------------------ [2018-12-17 15:05:57] taylor at laravel dot com Description: ------------ We received multiple bug reports to the Laravel framework Git issue tracker and I was able to confirm the following bug on my own machine as well. GitHub thread is here: https://github.com/laravel/framework/issues/26819 Laravel's dependency injection container uses Closures to resolve objects. We are encountering a bug in the following section of code: https://gist.github.com/taylorotwell/2a0934fcd5bb59e74640c9e451e69ec4 A $mailer instance is created on line 6... However, we when we interact with the mailer on line 11, PHP throws an error that the setQueue method does not exist on the Container object (which is the $app variable). It appears PHP thinks the $mailer variable is the $app variable. I am able to resolve the error by disabling Opcache entirely. With Opcache enabled, I will get the error fairly frequently, although it does seem to sometimes resolve itself. It will always reappear if I restart PHP-FPM and Opcache is enabled. I'm not sure of the best way to create a small, re-producable example of the bug. However, it seems to be affecting many users and be entirely Opcache related. Expected result: ---------------- PHP should call the setQueue method on the $mailer variable which is an instance of Mailer. Actual result: -------------- PHP calls the setQueue method on the value of the $app variable. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77310&edit=1

« previous php.bugs (#218500) next »