From 867fdec2845fc89db8f76f06cf8e007bc89fbf62 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 18 Aug 2023 22:23:40 +0100 Subject: [PATCH] [pools] remove mysql-specific bits --- ext/pools/main.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ext/pools/main.php b/ext/pools/main.php index f25bd1ffd..34f872a1d 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -135,9 +135,10 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) id SCORE_AIPK, user_id INTEGER NOT NULL, public BOOLEAN NOT NULL DEFAULT FALSE, - title VARCHAR(255) NOT NULL, + title VARCHAR(255) NOT NULL UNIQUE, description TEXT, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + lastupdated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, posts INTEGER NOT NULL DEFAULT 0, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); @@ -164,12 +165,6 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) log_info("pools", "extension installed"); } - if ($this->get_version("ext_pools_version") < 2) { - $database->execute("ALTER TABLE pools ADD UNIQUE INDEX (title);"); - $database->execute("ALTER TABLE pools ADD lastupdated TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;"); - - $this->set_version("ext_pools_version", 3); // skip 2 - } if ($this->get_version("ext_pools_version") < 4) { $database->standardise_boolean("pools", "public"); $this->set_version("ext_pools_version", 4); @@ -403,7 +398,7 @@ public function onPageRequest(PageRequestEvent $event) case "edit_description": if ($this->have_permission($user, $pool)) { $database->execute( - "UPDATE pools SET description=:dsc WHERE id=:pid", + "UPDATE pools SET description=:dsc,lastupdated=CURRENT_TIMESTAMP WHERE id=:pid", ["dsc" => $_POST['description'], "pid" => $pool_id] ); $page->set_mode(PageMode::REDIRECT); @@ -983,7 +978,7 @@ private function update_count(int $pool_id) { global $database; $database->execute( - "UPDATE pools SET posts=(SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid) WHERE id=:pid", + "UPDATE pools SET posts=(SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid),lastupdated=CURRENT_TIMESTAMP WHERE id=:pid", ["pid" => $pool_id] ); }