From 9e2522f86ffe05df5dbe57ac14150a40cb7fe59e Mon Sep 17 00:00:00 2001 From: Yaro <yarogeek@gmail.com> Date: Tue, 4 Oct 2011 17:03:53 +0400 Subject: [PATCH] fixed unpredictable working directory inside register_shutdown_function --- core/util.inc.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 7b51be91..e855e673 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1030,11 +1030,14 @@ function _start_coverage() { function _end_coverage() { if(function_exists("xdebug_get_code_coverage")) { - if(!file_exists("data/coverage")) mkdir("data/coverage"); + // Absolute path is necessary because working directory + // inside register_shutdown_function is unpredictable. + $absolute_path = dirname(dirname(__FILE__)) . "/data/coverage"; + if(!file_exists($absolute_path)) mkdir($absolute_path); $n = 0; $t = time(); - while(file_exists("data/coverage/$t.$n.log")) $n++; - file_put_contents("data/coverage/$t.$n.log", serialize(xdebug_get_code_coverage())); + while(file_exists("$absolute_path/$t.$n.log")) $n++; + file_put_contents("$absolute_path/$t.$n.log", serialize(xdebug_get_code_coverage())); } } ?>