Skip to content

Commit

Permalink
Fix #73546: Logging for opcache has an empty file name
Browse files Browse the repository at this point in the history
  • Loading branch information
mhagstrand authored and nikic committed Nov 16, 2016
1 parent 71ee641 commit 1d8be7c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ PHP NEWS
(Anatol)

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

- PCRE:
. Fixed bug #73392 (A use-after-free in zend allocator management).
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
/* store script structure in the hash table */
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);
if (bucket) {
zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", new_persistent_script->full_path);
zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", ZSTR_VAL(new_persistent_script->full_path));
if (key &&
/* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
memcmp(key, "phar://", sizeof("phar://") - 1) != 0 &&
Expand Down Expand Up @@ -1806,7 +1806,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
if (checksum != persistent_script->dynamic_members.checksum ) {
/* The checksum is wrong */
zend_accel_error(ACCEL_LOG_INFO, "Checksum failed for '%s': expected=0x%0.8X, found=0x%0.8X",
persistent_script->full_path, persistent_script->dynamic_members.checksum, checksum);
ZSTR_VAL(persistent_script->full_path), persistent_script->dynamic_members.checksum, checksum);
zend_shared_alloc_lock();
if (!persistent_script->corrupted) {
persistent_script->corrupted = 1;
Expand Down
19 changes: 19 additions & 0 deletions ext/opcache/tests/basic_logging.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Test basic logging for the Opcache
--DESCRIPTION--
This test runs a simple PHP script and ensures the Opcache
outputs the correct logging at the highest log_verbosity_level

--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.log_verbosity_level=4
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
echo "Foo Bar\n";
?>
--EXPECTF--
%s Message Cached script '%sbasic_logging%s'
Foo Bar

0 comments on commit 1d8be7c

Please sign in to comment.