diff --git a/core/database.php b/core/database.php index e8c6fca0..a150c479 100644 --- a/core/database.php +++ b/core/database.php @@ -129,7 +129,7 @@ class Database $this->dbtime += $dur; } - public function set_timeout(int $time): void + public function set_timeout(?int $time): void { $this->engine->set_timeout($this->db, $time); } diff --git a/core/dbengine.php b/core/dbengine.php index 355cd099..e0436bff 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -23,7 +23,7 @@ abstract class DBEngine return 'CREATE TABLE '.$name.' ('.$data.')'; } - abstract public function set_timeout(PDO $db, int $time); + abstract public function set_timeout(PDO $db, ?int $time); abstract public function get_version(PDO $db): string; @@ -53,7 +53,7 @@ class MySQL extends DBEngine return 'CREATE TABLE '.$name.' ('.$data.') '.$ctes; } - public function set_timeout(PDO $db, int $time): void + public function set_timeout(PDO $db, ?int $time): void { // These only apply to read-only queries, which appears to be the best we can to mysql-wise // $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";"); @@ -98,8 +98,9 @@ class PostgreSQL extends DBEngine return "CREATE TABLE $name ($data)"; } - public function set_timeout(PDO $db, int $time): void + public function set_timeout(PDO $db, ?int $time): void { + if(is_null($time)) $time = 0; $db->exec("SET statement_timeout TO ".$time.";"); } @@ -210,7 +211,7 @@ class SQLite extends DBEngine return "CREATE TABLE $name ($cols_redone); $extras"; } - public function set_timeout(PDO $db, int $time): void + public function set_timeout(PDO $db, ?int $time): void { // There doesn't seem to be such a thing for SQLite, so it does nothing } diff --git a/ext/admin/main.php b/ext/admin/main.php index 31b25eb2..3df07dbe 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -48,7 +48,7 @@ class AdminPage extends Extension if ($user->check_auth_token()) { log_info("admin", "Util: $action"); set_time_limit(0); - $database->set_timeout(300000); + $database->set_timeout(null); send_event($aae); } diff --git a/ext/approval/main.php b/ext/approval/main.php index 1ac6c764..df58429a 100644 --- a/ext/approval/main.php +++ b/ext/approval/main.php @@ -77,14 +77,14 @@ class Approval extends Extension $approval_action = $_POST["approval_action"]; switch ($approval_action) { case "approve_all": - $database->set_timeout(300000); // These updates can take a little bit + $database->set_timeout(null); // These updates can take a little bit $database->execute( "UPDATE images SET approved = :true, approved_by_id = :approved_by_id WHERE approved = :false", ["approved_by_id"=>$user->id, "true"=>true, "false"=>false] ); break; case "disapprove_all": - $database->set_timeout(300000); // These updates can take a little bit + $database->set_timeout(null); // These updates can take a little bit $database->execute( "UPDATE images SET approved = :false, approved_by_id = NULL WHERE approved = :true", ["true"=>true, "false"=>false] diff --git a/ext/mime/main.php b/ext/mime/main.php index e0bc6225..ea4ccbde 100644 --- a/ext/mime/main.php +++ b/ext/mime/main.php @@ -31,7 +31,7 @@ class MimeSystem extends Extension // them into one big transaction would not be a good idea. $database->commit(); } - $database->set_timeout(300000); // These updates can take a little bit + $database->set_timeout(null); // These updates can take a little bit $extensions = $database->get_col_iterable("SELECT DISTINCT ext FROM images"); diff --git a/ext/rating/main.php b/ext/rating/main.php index a3b63d44..8c2aa40c 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -534,7 +534,7 @@ class Ratings extends Extension break; } - $database->set_timeout(300000); // These updates can take a little bit + $database->set_timeout(null); // These updates can take a little bit $database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new"=>'?', "old"=>'u' ]); diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 753d901d..77fcf0dc 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -11,7 +11,7 @@ class Upgrade extends Extension if ($event->cmd == "db-upgrade") { print("Running DB Upgrade\n"); global $database; - $database->set_timeout(300000); // These updates can take a little bit + $database->set_timeout(null); // These updates can take a little bit send_event(new DatabaseUpgradeEvent()); } } @@ -156,7 +156,7 @@ class Upgrade extends Extension break; } - $database->set_timeout(300000); // These updates can take a little bit + $database->set_timeout(null); // These updates can take a little bit log_info("upgrade", "Setting index for ext column"); $database->execute('CREATE INDEX images_ext_idx ON images(ext)');