Revert "Use faster query to fetch entry counts"

This reverts commit 95bdf49
This commit is contained in:
ruan 2018-10-11 04:58:53 +02:00
parent 90f854eb71
commit 4b85ad4f81
No known key found for this signature in database
GPG Key ID: 0D2EC1C52E469C0B
2 changed files with 17 additions and 9 deletions

View File

@ -14,10 +14,10 @@ function __construct($page) {
$t_kicks = $t['kicks']; $t_kicks = $t['kicks'];
try { try {
$st = $page->conn->query("SELECT $st = $page->conn->query("SELECT
(SELECT id FROM $t_bans ORDER BY id DESC LIMIT 1), (SELECT COUNT(*) FROM $t_bans),
(SELECT id FROM $t_mutes ORDER BY id DESC LIMIT 1), (SELECT COUNT(*) FROM $t_mutes),
(SELECT id FROM $t_warnings ORDER BY id DESC LIMIT 1), (SELECT COUNT(*) FROM $t_warnings),
(SELECT id FROM $t_kicks ORDER BY id DESC LIMIT 1)"); (SELECT COUNT(*) FROM $t_kicks)");
($row = $st->fetch(PDO::FETCH_NUM)) or die('Failed to fetch row counts.'); ($row = $st->fetch(PDO::FETCH_NUM)) or die('Failed to fetch row counts.');
$st->closeCursor(); $st->closeCursor();
$this->count = array( $this->count = array(

View File

@ -231,24 +231,26 @@ final class Settings {
redirect("error/outdated-plugin.php"); redirect("error/outdated-plugin.php");
} }
} }
if ($settings->error_reporting) { if ($settings->error_reporting === false) {
die("Database error: $message");
} else {
die("Database error"); die("Database error");
} }
die("Database error: $message");
} }
private function test_strftime() { private function test_strftime() {
// If you modify this function, you may get an "Assertion failed" error. // If you modify this function, you may get an "Assertion failed" error.
date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
$fail = false;
$test = gmstrftime($this->date_format, 0); $test = gmstrftime($this->date_format, 0);
if ($test == false) { if ($test == false) {
ob_start(); ob_start();
var_dump($test); var_dump($test);
$testdump = ob_get_clean(); $testdump = ob_get_clean();
die("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump"); echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
$fail = true;
} }
$test = gmstrftime("%Y-%m-%d %H:%M", 0); $test = gmstrftime("%Y-%m-%d %H:%M", 0);
@ -256,7 +258,13 @@ final class Settings {
ob_start(); ob_start();
var_dump($test); var_dump($test);
$testdump = ob_get_clean(); $testdump = ob_get_clean();
die("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>Actual result: $testdump"); echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>");
echo("Actual result: $testdump");
$fail = true;
}
if ($fail === true) {
die;
} }
} }
} }