diff --git a/core/util.inc.php b/core/util.inc.php index d6848538..4138965d 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -991,11 +991,15 @@ function _start_coverage() { function _end_coverage() { if(function_exists("xdebug_get_code_coverage")) { - if(!file_exists("data/coverage")) mkdir("data/coverage"); - $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())); + $dir = getcwd(); + $end_cov = function() use ( $dir ) { + if(!file_exists("$dir/data/coverage")) mkdir("$dir/data/coverage"); + $n = 0; + $t = time(); + while(file_exists("$dir/data/coverage/$t.$n.log")) $n++; + file_put_contents("$dir/data/coverage/$t.$n.log", serialize(xdebug_get_code_coverage())); + }; + return $end_cov; } } ?> diff --git a/index.php b/index.php index 15a4e2c0..22137809 100644 --- a/index.php +++ b/index.php @@ -68,7 +68,7 @@ require_once "config.php"; require_once "core/util.inc.php"; if(COVERAGE) { _start_coverage(); - register_shutdown_function("_end_coverage"); + register_shutdown_function(_end_coverage()); } _version_check(); _sanitise_environment();