From 3c78b5685e382911f4a46447a7054d625a1067cc Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 9 Feb 2020 16:08:35 +0000 Subject: [PATCH] remove runtime-coverage -- when we want coverage, we enable it at the PHP runtime level --- core/sys_config.php | 1 - core/util.php | 71 --------------------------------------------- tests/defines.php | 1 - 3 files changed, 73 deletions(-) diff --git a/core/sys_config.php b/core/sys_config.php index ac5b93ff..ebf0a1ed 100644 --- a/core/sys_config.php +++ b/core/sys_config.php @@ -22,7 +22,6 @@ _d("DATABASE_DSN", null); // string PDO database connection details _d("DATABASE_TIMEOUT", 10000);// int Time to wait for each statement to complete _d("CACHE_DSN", null); // string cache connection details _d("DEBUG", false); // boolean print various debugging details -_d("COVERAGE", false); // boolean activate xdebug coverage monitor _d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers _d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes _d("SPEED_HAX", false); // boolean do some questionable things in the name of performance diff --git a/core/util.php b/core/util.php index 15ec46c7..ba13bc8b 100644 --- a/core/util.php +++ b/core/util.php @@ -322,42 +322,6 @@ function transload(string $url, string $mfile): ?array return null; } -/** - * Get the active contents of a .php file - */ -function manual_include(string $fname): ?string -{ - static $included = []; - - if (!file_exists($fname)) { - return null; - } - - if (in_array($fname, $included)) { - return null; - } - - $included[] = $fname; - - print "$fname\n"; - - $text = file_get_contents($fname); - - // we want one continuous file - $text = str_replace('<'.'?php', '', $text); - $text = str_replace('?'.'>', '', $text); - - // most requires are built-in, but we want /lib separately - $text = str_replace('require_', '// require_', $text); - $text = str_replace('// require_once "lib', 'require_once "lib', $text); - - // @include_once is used for user-creatable config files - $text = preg_replace('/@include_once "(.*)";/e', "manual_include('$1')", $text); - - return $text; -} - - function path_to_tags(string $path): string { $matches = []; @@ -562,11 +526,6 @@ date and you should plan on moving elsewhere. $tracer_enabled = constant('TRACE_FILE')!==null; $_tracer = new EventTracer(); - if (COVERAGE) { - _start_coverage(); - register_shutdown_function("_end_coverage"); - } - ob_start(); if (PHP_SAPI === 'cli' || PHP_SAPI == 'phpdbg') { @@ -666,36 +625,6 @@ function _get_query(): string } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ -* Code coverage * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -function _start_coverage(): void -{ - if (function_exists("xdebug_start_code_coverage")) { - #xdebug_start_code_coverage(XDEBUG_CC_UNUSED|XDEBUG_CC_DEAD_CODE); - xdebug_start_code_coverage(XDEBUG_CC_UNUSED); - } -} - -function _end_coverage(): void -{ - if (function_exists("xdebug_get_code_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("$absolute_path/$t.$n.log")) { - $n++; - } - file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage()))); - } -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * HTML Generation * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/tests/defines.php b/tests/defines.php index 51a9ccc7..93d74f0d 100644 --- a/tests/defines.php +++ b/tests/defines.php @@ -6,7 +6,6 @@ define("DATABASE_DSN", null); define("DATABASE_TIMEOUT", 10000); define("CACHE_DSN", null); define("DEBUG", false); -define("COVERAGE", false); define("CACHE_HTTP", false); define("COOKIE_PREFIX", 'shm'); define("SPEED_HAX", false);