Doc #75070 [Csd]: opcache_get_status returns opcache_enabled=false

[email protected]
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=75070&edit=1

 ID:                 75070
 Updated by:         [email protected]
 Reported by:        humbads at alum dot mit dot edu
 Summary:            opcache_get_status returns opcache_enabled=false
 Status:             Closed
 Type:               Documentation Problem
 Package:            opcache
 Operating System:   FreeBSD 10.3-RELEASE-p11
 PHP Version:        7.0.22
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> Could we remark this as a bug?

Consider to open a feature request. :)


Previous Comments:
------------------------------------------------------------------------
[2021-10-15 13:31:15] [email protected]

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

------------------------------------------------------------------------
[2019-09-03 13:38:23] 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.

------------------------------------------------------------------------
[2017-08-17 13:38:00] 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.

------------------------------------------------------------------------
[2017-08-13 14:35:04] 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)
}


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75070&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.