From 516c1a8374380660f1994a11fab87a3d5d8a651d Mon Sep 17 00:00:00 2001 From: Jay Trees Date: Tue, 18 Jan 2022 14:59:43 +0100 Subject: [PATCH] Fix version updater --- includes/classes/options.php | 14 ++++---------- includes/pages/update.php | 5 ++--- index.php | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/includes/classes/options.php b/includes/classes/options.php index e1130aa4..a20761f6 100644 --- a/includes/classes/options.php +++ b/includes/classes/options.php @@ -43,15 +43,9 @@ class Options public function setOption(string $key, string $value): void { - try { - $option = $this->database->query('UPDATE `options` - SET `value` - WHERE `key` = ' . $key . ' - ;'); - - $value = $option['value'] ?? ''; - } catch (\Throwable $th) { - //throw $th; - } + $this->database->query('UPDATE `options` + SET `value` = "' . $value . '" + WHERE `key` = "' . $key . '" + ;'); } } diff --git a/includes/pages/update.php b/includes/pages/update.php index 0a0d8151..dda5ffc1 100644 --- a/includes/pages/update.php +++ b/includes/pages/update.php @@ -34,11 +34,10 @@ if ('POST' === $_SERVER['REQUEST_METHOD']) { $database->query('ALTER TABLE `wishlists` ADD INDEX(`hash`);'); $database->query('INSERT INTO `options` (`key`, `value`) VALUES ("version", "' . VERSION . '");'); - - // Use this for future versions since it didn't existsin 0.1.0 - // $options->setOption('version', VERSION); } + $options->setOption('version', VERSION); + header('Location: /?page=home'); die(); } diff --git a/index.php b/index.php index 59431e29..80c2514d 100644 --- a/index.php +++ b/index.php @@ -77,7 +77,7 @@ if ($options) { /** * Update */ -define('VERSION', '0.2.0'); +define('VERSION', '0.2.1'); if ($options) { if (-1 === version_compare($options->version, VERSION)) {