From 1d8be7c044c0e4a7d985e7b02fe81644a636542d Mon Sep 17 00:00:00 2001 From: Mitch Hagstrand Date: Wed, 16 Nov 2016 12:00:52 -0800 Subject: [PATCH] Fix #73546: Logging for opcache has an empty file name --- NEWS | 3 ++- ext/opcache/ZendAccelerator.c | 4 ++-- ext/opcache/tests/basic_logging.phpt | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 ext/opcache/tests/basic_logging.phpt diff --git a/NEWS b/NEWS index d164457711..b4c3249efa 100644 --- a/NEWS +++ b/NEWS @@ -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). diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 11724c4eda..230cc3d20c 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -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 && @@ -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; diff --git a/ext/opcache/tests/basic_logging.phpt b/ext/opcache/tests/basic_logging.phpt new file mode 100644 index 0000000000..c62ea039a5 --- /dev/null +++ b/ext/opcache/tests/basic_logging.phpt @@ -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-- + +--FILE-- + +--EXPECTF-- +%s Message Cached script '%sbasic_logging%s' +Foo Bar -- 2.50.1