php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71621 opcache_reset sometimes returns false
Submitted: 2016-02-18 08:44 UTC Modified: 2021-10-24 04:22 UTC
Votes:9
Avg. Score:4.4 ± 1.0
Reproduced:7 of 7 (100.0%)
Same Version:1 (14.3%)
Same OS:4 (57.1%)
From: sts at ono dot at Assigned: cmb (profile)
Status: No Feedback Package: opcache
PHP Version: 5.6.18 OS: Debian/Jessie
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sts at ono dot at
New email:
PHP Version: OS:

 

 [2016-02-18 08:44 UTC] sts at ono dot at
Description:
------------
There seems to be a race condition under which opcache_reset() returns false, although the opcache extension is loaded.

Make sure the opcache extension is loaded. Create the Test script on a webserver and call it a couple of times. In most cases it will return true, but sometimes it returns false.

Please note I reproduced this on a server where requests are actually coming in.

This also happens during our deployment, where we call opcache_reset() only once. It also happened among projects with different codebases (Laravel, ZF, self coded), so it doesn't seem to be related to our code. 

Test script:
---------------
<?php echo opcache_reset();


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-17 03:57 UTC] detailyang at gmail dot com
hey, guys.
I make a bet, you havent check opcache status before. So reset code as follow if you can:
    $opcache_status = opcache_get_status();
    if (isset($opcache_status["opcache_enabled"]) && !$opcache_status["opcache_enabled"]) {
        echo "opcache empty, so skip it";
        exit(0);
    }

    // now you can reset opcache


have a fun to you:)
 [2019-08-05 15:15 UTC] mail at franek dot fr
Able to reproduce on CentOS 7 with:
PHP 7.3.8 (cli) (built: Jul 30 2019 09:26:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.8, Copyright (c) 1999-2018, by Zend Technologies
 [2021-10-15 14:34 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-10-15 14:34 UTC] cmb@php.net
> I make a bet, you havent check opcache status before.

Indeed, either that, or opcache.restrict_api is effective.  (On
Windows, the function will also return false, if the file cache
fallback is effective).

So, if anybody still has that issue with any of the actively
supported PHP versions[1], please check the above.

[1] <https://www.php.net/supported-versions.php>
 [2021-10-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 03:01:29 2024 UTC