mirror of
https://github.com/vrana/adminer.git
synced 2025-08-17 20:01:25 +02:00
Save coverage to database
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@906 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
error_reporting(4343); // errors and warnings
|
||||
|
||||
include "../adminer/include/coverage.inc.php";
|
||||
|
||||
// disable filter.default
|
||||
$filter = (!ereg('^(unsafe_raw)?$', ini_get("filter.default")) || ini_get("filter.default_flags"));
|
||||
if ($filter) {
|
||||
@@ -44,21 +46,6 @@ if (!ini_get("session.auto_start")) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["coverage"])) {
|
||||
// coverage is used in tests and removed in compilation
|
||||
function save_coverage() {
|
||||
foreach (xdebug_get_code_coverage() as $filename => $lines) {
|
||||
foreach ($lines as $l => $val) {
|
||||
if (!$_SESSION["coverage"][$filename][$l] || $val > 0) {
|
||||
$_SESSION["coverage"][$filename][$l] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
|
||||
register_shutdown_function('save_coverage');
|
||||
}
|
||||
|
||||
// disable magic quotes to be able to use database escaping function
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$process = array(&$_GET, &$_POST, &$_COOKIE);
|
||||
@@ -86,9 +73,6 @@ include "../adminer/include/lang.inc.php";
|
||||
include "../adminer/lang/$LANG.inc.php";
|
||||
include "./include/adminer.inc.php";
|
||||
include "../adminer/include/design.inc.php";
|
||||
if (isset($_GET["coverage"])) {
|
||||
include "../adminer/coverage.inc.php";
|
||||
}
|
||||
include "../adminer/include/pdo.inc.php";
|
||||
include "../adminer/include/mysql.inc.php";
|
||||
include "../adminer/include/auth.inc.php";
|
||||
|
25
adminer/include/coverage.inc.php
Normal file
25
adminer/include/coverage.inc.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
// coverage is used in tests and removed in compilation
|
||||
if (extension_loaded("xdebug") && function_exists('mysql_query') && mysql_query('SELECT 1 FROM adminer_test.coverage LIMIT 0')) {
|
||||
function save_coverage() {
|
||||
$coverage = array();
|
||||
$result = mysql_query("SELECT filename, coverage_serialize FROM adminer_test.coverage");
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
$coverage[$row["filename"]] = unserialize($row["coverage_serialize"]);
|
||||
}
|
||||
mysql_free_result($result);
|
||||
foreach (xdebug_get_code_coverage() as $filename => $lines) {
|
||||
foreach ($lines as $l => $val) {
|
||||
if (!$coverage[$filename][$l] || $val > 0) {
|
||||
$coverage[$filename][$l] = $val;
|
||||
}
|
||||
}
|
||||
mysql_query("
|
||||
REPLACE adminer_test.coverage (filename, coverage_serialize)
|
||||
VALUES ('" . mysql_real_escape_string($filename) . "', '" . mysql_real_escape_string(serialize($coverage[$filename])) . "')
|
||||
");
|
||||
}
|
||||
}
|
||||
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
|
||||
register_shutdown_function('save_coverage');
|
||||
}
|
@@ -46,7 +46,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||
if (strlen($_GET["db"]) && $databases && !in_array($_GET["db"], $databases, true)) {
|
||||
$databases = null;
|
||||
}
|
||||
if (isset($databases) && !isset($_GET["sql"]) && !isset($_SESSION["coverage"])) {
|
||||
if (isset($databases) && !isset($_GET["sql"])) {
|
||||
// improves concurrency if a user opens several pages at once
|
||||
session_write_close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user