Skip to content

Commit 1d8be7c

Browse files
mhagstrandnikic
authored andcommitted
Fix #73546: Logging for opcache has an empty file name
1 parent 71ee641 commit 1d8be7c

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ PHP NEWS
1717
(Anatol)
1818

1919
- Opcache:
20-
. Fixed bug #69090 (check cached files permissions)
20+
. Fixed bug #69090 (check cached files permissions). (dmitry)
21+
. Fixed bug #73546 (Logging for opcache has an empty file name). (mhagstrand)
2122

2223
- PCRE:
2324
. Fixed bug #73392 (A use-after-free in zend allocator management).

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
13391339
/* store script structure in the hash table */
13401340
bucket = zend_accel_hash_update(&ZCSG(hash), ZSTR_VAL(new_persistent_script->full_path), ZSTR_LEN(new_persistent_script->full_path), 0, new_persistent_script);
13411341
if (bucket) {
1342-
zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", new_persistent_script->full_path);
1342+
zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", ZSTR_VAL(new_persistent_script->full_path));
13431343
if (key &&
13441344
/* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
13451345
memcmp(key, "phar://", sizeof("phar://") - 1) != 0 &&
@@ -1806,7 +1806,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
18061806
if (checksum != persistent_script->dynamic_members.checksum ) {
18071807
/* The checksum is wrong */
18081808
zend_accel_error(ACCEL_LOG_INFO, "Checksum failed for '%s': expected=0x%0.8X, found=0x%0.8X",
1809-
persistent_script->full_path, persistent_script->dynamic_members.checksum, checksum);
1809+
ZSTR_VAL(persistent_script->full_path), persistent_script->dynamic_members.checksum, checksum);
18101810
zend_shared_alloc_lock();
18111811
if (!persistent_script->corrupted) {
18121812
persistent_script->corrupted = 1;

ext/opcache/tests/basic_logging.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Test basic logging for the Opcache
3+
--DESCRIPTION--
4+
This test runs a simple PHP script and ensures the Opcache
5+
outputs the correct logging at the highest log_verbosity_level
6+
7+
--INI--
8+
opcache.enable=1
9+
opcache.enable_cli=1
10+
opcache.log_verbosity_level=4
11+
--SKIPIF--
12+
<?php require_once('skipif.inc'); ?>
13+
--FILE--
14+
<?php
15+
echo "Foo Bar\n";
16+
?>
17+
--EXPECTF--
18+
%s Message Cached script '%sbasic_logging%s'
19+
Foo Bar

0 commit comments

Comments
 (0)