mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-23 08:29:06 +00:00
Use faster query to fetch entry counts
This commit is contained in:
parent
ea93ca37bd
commit
95bdf49a6a
@ -14,10 +14,10 @@ function __construct($page) {
|
||||
$t_kicks = $t['kicks'];
|
||||
try {
|
||||
$st = $page->conn->query("SELECT
|
||||
(SELECT COUNT(*) FROM $t_bans),
|
||||
(SELECT COUNT(*) FROM $t_mutes),
|
||||
(SELECT COUNT(*) FROM $t_warnings),
|
||||
(SELECT COUNT(*) FROM $t_kicks)");
|
||||
(SELECT id FROM $t_bans ORDER BY id DESC LIMIT 1),
|
||||
(SELECT id FROM $t_mutes ORDER BY id DESC LIMIT 1),
|
||||
(SELECT id FROM $t_warnings ORDER BY id DESC LIMIT 1),
|
||||
(SELECT id FROM $t_kicks ORDER BY id DESC LIMIT 1)");
|
||||
($row = $st->fetch(PDO::FETCH_NUM)) or die('Failed to fetch row counts.');
|
||||
$st->closeCursor();
|
||||
$this->count = array(
|
||||
|
@ -231,26 +231,24 @@ final class Settings {
|
||||
redirect("error/outdated-plugin.php");
|
||||
}
|
||||
}
|
||||
if ($settings->error_reporting === false) {
|
||||
if ($settings->error_reporting) {
|
||||
die("Database error: $message");
|
||||
} else {
|
||||
die("Database error");
|
||||
}
|
||||
die("Database error: $message");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function test_strftime() {
|
||||
// If you modify this function, you may get an "Assertion failed" error.
|
||||
date_default_timezone_set("UTC"); // temporarily set UTC timezone for testing purposes
|
||||
|
||||
$fail = false;
|
||||
$test = gmstrftime($this->date_format, 0);
|
||||
if ($test == false) {
|
||||
ob_start();
|
||||
var_dump($test);
|
||||
$testdump = ob_get_clean();
|
||||
echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
|
||||
$fail = true;
|
||||
die("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump");
|
||||
}
|
||||
|
||||
$test = gmstrftime("%Y-%m-%d %H:%M", 0);
|
||||
@ -258,13 +256,7 @@ final class Settings {
|
||||
ob_start();
|
||||
var_dump($test);
|
||||
$testdump = ob_get_clean();
|
||||
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;
|
||||
die("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"<br>Actual result: $testdump");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user