php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75070 opcache_get_status returns opcache_enabled=false
Submitted: 2017-08-13 14:35 UTC Modified: 2021-10-15 13:32 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: humbads at alum dot mit dot edu Assigned: cmb (profile)
Status: Closed Package: opcache
PHP Version: 7.0.22 OS: FreeBSD 10.3-RELEASE-p11
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: humbads at alum dot mit dot edu
New email:
PHP Version: OS:

 

 [2017-08-13 14:35 UTC] humbads at alum dot mit dot edu
Description:
------------
Running PHP CLI, opcache_get_status returns opcache_enabled=false when file_cache_only=1.  It should return opcache_enabled=true, unless that only applies to the SHM cache.  If that's the case, then the documentation should make that clear.  The documentation should also indicate that detailed statistics will not be available when file-only caching is turned on, although that's a little easier to understand why.

PHPinfo reports "Opcode Caching => Up and Running", and I see the .php.bin files being generated and updated in the file cache folder.  So it does seem that opcache is enabled and working for CLI.

Here is some more configuration information:


Results of opcache_get_configuration:
array(3) {
  ["directives"]=>
  array(30) {
    ["opcache.enable"]=>
    bool(true)
    ["opcache.enable_cli"]=>
    bool(true)
    ["opcache.use_cwd"]=>
    bool(true)
    ["opcache.validate_timestamps"]=>
    bool(true)
    ["opcache.validate_permission"]=>
    bool(false)
    ["opcache.validate_root"]=>
    bool(false)
    ["opcache.inherited_hack"]=>
    bool(true)
    ["opcache.dups_fix"]=>
    bool(false)
    ["opcache.revalidate_path"]=>
    bool(false)
    ["opcache.log_verbosity_level"]=>
    int(1)
    ["opcache.memory_consumption"]=>
    int(67108864)
    ["opcache.interned_strings_buffer"]=>
    int(4)
    ["opcache.max_accelerated_files"]=>
    int(2000)
    ["opcache.max_wasted_percentage"]=>
    float(0.05)
    ["opcache.consistency_checks"]=>
    int(0)
    ["opcache.force_restart_timeout"]=>
    int(180)
    ["opcache.revalidate_freq"]=>
    int(2)
    ["opcache.preferred_memory_model"]=>
    string(0) ""
    ["opcache.blacklist_filename"]=>
    string(0) ""
    ["opcache.max_file_size"]=>
    int(0)
    ["opcache.error_log"]=>
    string(0) ""
    ["opcache.protect_memory"]=>
    bool(false)
    ["opcache.save_comments"]=>
    bool(true)
    ["opcache.fast_shutdown"]=>
    bool(true)
    ["opcache.enable_file_override"]=>
    bool(false)
    ["opcache.optimization_level"]=>
    int(2147467263)
    ["opcache.lockfile_path"]=>
    string(4) "/tmp"
    ["opcache.file_cache"]=>
    string(20) "/var/tmp/php_opcache"
    ["opcache.file_cache_only"]=>
    bool(true)
    ["opcache.file_cache_consistency_checks"]=>
    bool(true)
  }
  ["version"]=>
  array(2) {
    ["version"]=>
    string(6) "7.0.22"
    ["opcache_product_name"]=>
    string(12) "Zend OPcache"
  }
  ["blacklist"]=>
  array(0) {
  }
}

Results of phpinfo();
Zend OPcache

Opcode Caching => Up and Running
Optimization => Enabled
SHM Cache => Disabled
File Cache => Enabled
Startup => OK

Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 1 => 1
opcache.file_cache => /var/tmp/php_opcache => /var/tmp/php_opcache
opcache.file_cache_consistency_checks => 1 => 1 
opcache.file_cache_only => 1 => 1
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 4 => 4
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 2000 => 2000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 64 => 64  
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On



Test script:
---------------
php -r 'var_dump(opcache_get_configuration());'
php -r 'phpinfo();'
php -r 'var_dump(var_dump(opcache_get_status());'

Expected result:
----------------
array(3) {
  ["opcache_enabled"]=>
  bool(true)
  ["file_cache"]=>
  string(20) "/var/tmp/php_opcache"
  ["file_cache_only"]=>
  bool(true)
}

Actual result:
--------------
array(3) {
  ["opcache_enabled"]=>
  bool(false)
  ["file_cache"]=>
  string(20) "/var/tmp/php_opcache"
  ["file_cache_only"]=>
  bool(true)
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-17 13:38 UTC] humbads at alum dot mit dot edu
-Type: Bug +Type: Documentation Problem
 [2017-08-17 13:38 UTC] humbads at alum dot mit dot edu
I confirmed this behavior on PHP 7.0.22 on Windows 10.  When I change opcache.file_cache_only to "0", then opcache_enabled changes to "true" and all the statistics appear.  opcache_enabled seems to only indicate the status of memory cache, not opcache in general.  I changed this from a bug to a documentation problem.  It would be nice if all the values returned by opcache_get_status were documented.
 [2019-09-03 13:38 UTC] malone dot spencer at gmail dot com
Could we remark this as a bug? I understand that in the current implementation, this is just the status of the in memory cache, but my understanding is that opcache_get_status existed long before the file cache, and speaking as a consumer of this, I would be very very confused if the name of opcache_enabled is kept the same but we sneak in a doc update to specify that it's not actually the status of opcache, but instead is the status of a subset of features in opcache.
 [2021-10-15 13:31 UTC] git@php.net
Automatic comment on behalf of frederikbosch (author) and web-flow (committer)
Revision: https://github.com/php/doc-en/commit/50b104c116f6b1798e36bf2f56b1fa023b8a7a92
Log: Fix #75070: Opcache functions only apply to in-memory cache
 [2021-10-15 13:31 UTC] git@php.net
-Status: Open +Status: Closed
 [2021-10-15 13:32 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2021-10-15 13:32 UTC] cmb@php.net
> Could we remark this as a bug?

Consider to open a feature request. :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC