Skip to content

Commit 768ad70

Browse files
amnutsnikic
authored andcommitted
Fix bug #78291 Missing opcache directives
New opcache directives have been added recently which are returned if using `ini_get_all('zend opcache')` but are not listed in the directives if using `opcache_get_configuration()`. This fix adds those missing directives as well as if `opcache.mmap_base` is used instead of `opcache.lockfile_path`. Also adds a test to ensure the directives match with both methods of fetching.
1 parent a7de2af commit 768ad70

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

NEWS

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ PHP NEWS
77
(Joshua Westerheide)
88

99
- PDO_Sqlite:
10-
. Fixed #78192 (SegFault when reuse statement after schema has changed).
10+
. Fixed bug #78192 (SegFault when reuse statement after schema has changed).
1111
(Vincent Quatrevieux)
1212

1313
- SQLite:
1414
. Upgraded to SQLite 3.28.0. (cmb)
1515

1616
- XMLRPC:
17-
. Fixed #78173 (XML-RPC mutates immutable objects during encoding). (Asher
18-
Baker)
17+
. Fixed bug #78173 (XML-RPC mutates immutable objects during encoding).
18+
(Asher Baker)
1919

2020
- Date:
21-
. Fixed #69044 (discrepency between time and microtime). (krakjoe)
21+
. Fixed bug #69044 (discrepency between time and microtime). (krakjoe)
2222

2323
- Libxml:
2424
. Fixed bug #78279 (libxml_disable_entity_loader settings is shared between
@@ -36,11 +36,15 @@ PHP NEWS
3636
socket-to-stream). (Nikita)
3737

3838
- OPcache:
39-
. Fixed #78189 (file cache strips last character of uname hash). (cmb)
40-
. Fixed #78202 (Opcache stats for cache hits are capped at 32bit NUM). (cmb)
39+
. Fixed bug #78189 (file cache strips last character of uname hash). (cmb)
40+
. Fixed bug #78202 (Opcache stats for cache hits are capped at 32bit NUM).
41+
(cmb)
42+
. Fixed bug #78291 (opcache_get_configuration doesn't list all directives).
43+
(Andrew Collington)
4144

4245
- Standard:
43-
. Fixed #78241 (touch() does not handle dates after 2038 in PHP 64-bit). (cmb)
46+
. Fixed bug #78241 (touch() does not handle dates after 2038 in PHP 64-bit).
47+
(cmb)
4448

4549
27 Jun 2019, PHP 7.2.20
4650

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Test that the directives listed with `opcache_get_configuration` include all those from the ini settings.
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.opt_debug_level=0
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
$opts = opcache_get_configuration()['directives'];
12+
$inis = ini_get_all('zend opcache');
13+
var_dump(array_diff_key($inis, $opts));
14+
?>
15+
--EXPECT--
16+
array(0) {
17+
}

ext/opcache/zend_accelerator_module.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,13 +727,25 @@ static ZEND_FUNCTION(opcache_get_configuration)
727727

728728
#ifndef ZEND_WIN32
729729
add_assoc_string(&directives, "opcache.lockfile_path", STRING_NOT_NULL(ZCG(accel_directives).lockfile_path));
730+
#else
731+
add_assoc_string(&directives, "opcache.mmap_base", STRING_NOT_NULL(ZCG(accel_directives).mmap_base));
730732
#endif
731733

732734
#ifdef HAVE_OPCACHE_FILE_CACHE
733735
add_assoc_string(&directives, "opcache.file_cache", ZCG(accel_directives).file_cache ? ZCG(accel_directives).file_cache : "");
734736
add_assoc_bool(&directives, "opcache.file_cache_only", ZCG(accel_directives).file_cache_only);
735737
add_assoc_bool(&directives, "opcache.file_cache_consistency_checks", ZCG(accel_directives).file_cache_consistency_checks);
736738
#endif
739+
#if ENABLE_FILE_CACHE_FALLBACK
740+
add_assoc_bool(&directives, "opcache.file_cache_fallback", ZCG(accel_directives).file_cache_fallback);
741+
#endif
742+
743+
add_assoc_long(&directives, "opcache.file_update_protection", ZCG(accel_directives).file_update_protection);
744+
add_assoc_long(&directives, "opcache.opt_debug_level", ZCG(accel_directives).opt_debug_level);
745+
add_assoc_string(&directives, "opcache.restrict_api", STRING_NOT_NULL(ZCG(accel_directives).restrict_api));
746+
#ifdef HAVE_HUGE_CODE_PAGES
747+
add_assoc_bool(&directives, "opcache.huge_code_pages", ZCG(accel_directives).huge_code_pages);
748+
#endif
737749

738750
add_assoc_zval(return_value, "directives", &directives);
739751

0 commit comments

Comments
 (0)