php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70357 OPcache status is unavailable in shutdown
Submitted: 2015-08-25 12:20 UTC Modified: 2015-09-04 18:35 UTC
From: viktor at szepe dot net Assigned:
Status: Open Package: opcache
PHP Version: 7.0.0RC1 OS: Debian 8.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
44 - 29 = ?
Subscribe to this entry?

 
 [2015-08-25 12:20 UTC] viktor at szepe dot net
Description:
------------
opcache_get_status() returns false in shutdown but not before it.


PHP 7.0.0-dev (cli) (built: Aug 17 2015 19:10:40)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies


Test script:
---------------
function o1_opcache() {
    var_export( opcache_get_status() ); // false
}
register_shutdown_function( 'o1_opcache' );

Expected result:
----------------
OPcache status


Actual result:
--------------
false


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-25 12:21 UTC] viktor at szepe dot net
https://github.com/zendtech/ZendOptimizerPlus/issues/217
 [2015-08-26 06:13 UTC] laruence@php.net
I can not reproduce this.... 

$ sapi/cli/php /tmp/1.php
array (
  'opcache_enabled' => true,
  'cache_full' => false,
  'restart_pending' => false,
  'restart_in_progress' => false,
  'memory_usage' =>
   .........


thanks
 [2015-08-26 06:48 UTC] viktor at szepe dot net
I also get right output on cli:
php -d opcache.enable_cli=1 1.php

Could it be that my php.ini has wrong settings?

Opcode Caching 	Up and Running
Optimization 	Enabled
Startup 	OK
Shared memory model 	mmap
Cache hits 	107450
Cache misses 	798
Used memory 	36095392
Free memory 	30976152
Wasted memory 	37320
Interned Strings Used memory 	4194272
Interned Strings Free memory 	32
Cached scripts 	784
Cached keys 	1350
Max keys 	3907
OOM restarts 	0
Hash keys restarts 	0
Manual restarts 	0 

opcache.blacklist_filename	no value	no value
opcache.consistency_checks	0	0
opcache.dups_fix	Off	Off
opcache.enable	On	On
opcache.enable_cli	Off	Off
opcache.enable_file_override	Off	Off
opcache.error_log	no value	no value
opcache.fast_shutdown	1	1
opcache.file_update_protection	2	2
opcache.force_restart_timeout	180	180
opcache.inherited_hack	On	On
opcache.interned_strings_buffer	4	4
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	0xFFFFFFFF	0xFFFFFFFF
opcache.preferred_memory_model	no value	no value
opcache.protect_memory	0	0
opcache.restrict_api	/home/wp/website/	/home/wp/website/
opcache.revalidate_freq	0	0
opcache.revalidate_path	Off	Off
opcache.save_comments	1	1
opcache.use_cwd	On	On
opcache.validate_timestamps	On	On
 [2015-08-26 06:58 UTC] viktor at szepe dot net
It is very strange: after disabling opcache.restrict_api it is OK.
But opcache.restrict_api was "/home/wp/website/" and the only script is:

  'scripts' => 
  array (
    '/home/wp/website/html/opcache-status-in-shutdown.php' => 
    array (
      'full_path' => '/home/wp/website/html/opcache-status-in-shutdown.php',
      'hits' => 0,
      'memory_consumption' => 1288,
      'last_used' => 'Wed Aug 26 08:54:46 2015',
      'last_used_timestamp' => 1440572086,
      'timestamp' => 0,
    ),

How should I use opcache.restrict_api to get OPcache status?
 [2015-08-26 06:59 UTC] viktor at szepe dot net
Docs says:

If opcache.restrict_api is in use and the current path is in violation of the rule, an E_WARNING will be raised; no status information will be returned. 

Does '/home/wp/website/html/opcache-status-in-shutdown.php' violate "/home/wp/website/" ?
 [2015-08-26 07:02 UTC] viktor at szepe dot net
Maybe the current path changes in shutdown??
 [2015-08-26 07:05 UTC] viktor at szepe dot net
Yes. getcwd() returns "/" in shutdown.
Even setting opcache.restrict_api to "/" does not help.

Please advise.
 [2015-09-04 16:28 UTC] kalle@php.net
From register_shutdown_function():

  Note:
  Working directory of the script can change inside the shutdown function under some web servers, e.g. Apache.

Not sure what we can do about that as this sort of behavior have always been like it around other places of PHP
 [2015-09-04 18:35 UTC] viktor at szepe dot net
I think opcache.restrict_api is not interested in cwd but the path of the queried PHP script.

Before 7.0 I was able to get OPcache status in shutdown.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 12:01:25 2019 UTC