Bug #71296 [Com]: Opcache Fatal error when enabling opcache.file_cache_only

[email protected] ("max dot novikov at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=71296&edit=1

 ID:                 71296
 Comment by:         max dot novikov at gmail dot com
 Reported by:        cyberdevil001 at telenet dot be
 Summary:            Opcache Fatal error when enabling
                     opcache.file_cache_only
 Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   CentOS
 PHP Version:        7.0.1
 Block user comment: N
 Private report:     N

 New Comment:

I've experienced the same issue and found out that you cannot set absolute path for opcache directory, only relative, for reasons unknown. I.e.
/var/www/html/.opcache doesn't work
../html/.opcache does


Previous Comments:
------------------------------------------------------------------------
[2016-12-21 13:44:07] sailormax at inbox dot lv

Same problem on Windows. PHP 7.0.14/7.1.0

display_errors = On
display_startup_errors = On
error_reporting = E_ALL
extension_dir = ".\ext"
zend_extension=php_opcache.dll
opcache.enable = 1
opcache.enable_cli = 1
opcache.huge_code_pages = 1
opcache.file_cache = ".\temp\opcache"
opcache.file_cache_only = 1
opcache.file_cache_consistency_checks = 1
opcache.file_cache_fallback = 1

php --version
=> (13140): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache

------------------------------------------------------------------------
[2016-01-07 09:44:25] cyberdevil001 at telenet dot be

Was able to get it working by changing the path to:

opcache.file_cache=/home/admin/public_html/.opcache

Why is it not working with /tmp/.opcache while this folder is set in the open_basedir setting:
open_basedir	/home/admin/:/tmp:/var/tmp:/usr/local/lib/php/:/usr/local/php70/lib/php/

Changed the owner of /tmp/.opcache to admin which is the same as /home/admin/public_html/.opcache but still it doesn't work in the /tmp directory.

------------------------------------------------------------------------
[2016-01-07 09:15:05] cyberdevil001 at telenet dot be

Changed the log_verbosity_level to 3 with the following result:

Thu Jan  7 10:11:34 2016 (26904): Warning opcache.file_cache must be a full path of accessable directory.
Thu Jan  7 10:11:34 2016 (26904): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache

Information of the directory:

ls -al /tmp/.opcache/
totaal 8
drwxrwxrwx   2 root root 4096  5 jan 23:36 .
drwxrwxrwt. 15 root root 4096  7 jan 10:11 ..

So directory has all the rights to be used.
Checked the PHP code https://github.com/php/php-src/blob/master/ext/opcache/ZendAccelerator.c :


#ifdef HAVE_OPCACHE_FILE_CACHE
	} else if (!ZCG(accel_directives).file_cache) {
		accel_startup_ok = 0;
		zend_accel_error(ACCEL_LOG_FATAL, "opcache.file_cache_only is set without a proper setting of opcache.file_cache");
		return SUCCESS;
	} 

So this error will only be shown if opcache.file_cache is empty right? Which is not the case.

------------------------------------------------------------------------
[2016-01-07 03:30:51] [email protected]

try -d opcache.log_verbosity_level=3, it probably because /tmp/.opcache is not accessable

------------------------------------------------------------------------
[2016-01-06 23:04:43] cyberdevil001 at telenet dot be

Description:
------------
Configure Command =>  './configure'  '--prefix=/usr/local/php70' '--program-suffix=70' '--with-config-file-scan-dir=/usr/local/php70/lib/php.conf.d' '--with-curl=/usr/local/lib' '--with-gd' '--enable-gd-native-ttf' '--with-gettext' '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-libxml-dir=/usr/local/lib' '--with-kerberos' '--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=mysqlnd' '--with-pcre-regex=/usr/local' '--with-pdo-mysql=mysqlnd' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-xsl' '--with-zlib' '--with-zlib-dir=/usr/local/lib' '--enable-zip' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-sockets' '--enable-soap' '--enable-mbstring' '--with-icu-dir=/usr/local/icu' '--enable-opcache' '--enable-opcache-file' '--enable-opcache-filecache' '--enable-intl'

PHP.INI settings:
opcache.memory_consumption=32
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=3000
opcache.revalidate_freq=60
opcache.fast_shutdown=0
opcache.enable_cli=1
opcache.file_cache_only=1
opcache.file_cache=/tmp/.opcache/

Test script:
---------------
/usr/local/bin/php --version
PHP 7.0.1 (cli) (built: Jan  5 2016 23:49:38) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies


Opcache PHP info via CLI:

Zend OPcache

Opcode Caching => Disabled
Optimization => Disabled
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 => 0 => 0
opcache.file_cache => /tmp/.opcache/ => /tmp/.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 => 8 => 8
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 3000 => 3000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 32 => 32
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 60 => 60
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On



Expected result:
----------------
Opcache.file_cache_only should write files inside /tmp/.opcache and not show the error below because opcache.file_cache is actually set correct according to php-cli output. Error in logs is shown while running any script (for example: <?php phpinfo(); ?>)

Actual result:
--------------
tail -n 2 /var/log/httpd/error_log
Wed Jan  6 16:53:01 2016 (846663): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache
Wed Jan  6 16:53:03 2016 (846686): Fatal Error opcache.file_cache_only is set without a proper setting of opcache.file_cache


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



--
Edit this bug report at https://bugs.php.net/bug.php?id=71296&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.