Fix version updater

This commit is contained in:
Jay Trees 2022-01-18 14:59:43 +01:00
parent 1c5f86b830
commit 516c1a8374
3 changed files with 7 additions and 14 deletions

View file

@ -43,15 +43,9 @@ class Options
public function setOption(string $key, string $value): void public function setOption(string $key, string $value): void
{ {
try { $this->database->query('UPDATE `options`
$option = $this->database->query('UPDATE `options` SET `value` = "' . $value . '"
SET `value` WHERE `key` = "' . $key . '"
WHERE `key` = ' . $key . ' ;');
;');
$value = $option['value'] ?? '';
} catch (\Throwable $th) {
//throw $th;
}
} }
} }

View file

@ -34,11 +34,10 @@ if ('POST' === $_SERVER['REQUEST_METHOD']) {
$database->query('ALTER TABLE `wishlists` ADD INDEX(`hash`);'); $database->query('ALTER TABLE `wishlists` ADD INDEX(`hash`);');
$database->query('INSERT INTO `options` (`key`, `value`) VALUES ("version", "' . VERSION . '");'); $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'); header('Location: /?page=home');
die(); die();
} }

View file

@ -77,7 +77,7 @@ if ($options) {
/** /**
* Update * Update
*/ */
define('VERSION', '0.2.0'); define('VERSION', '0.2.1');
if ($options) { if ($options) {
if (-1 === version_compare($options->version, VERSION)) { if (-1 === version_compare($options->version, VERSION)) {