From f925e118c2f1fecad42a14fbd0f945f50bbb8e58 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sun, 28 Jun 2015 17:47:19 +0200 Subject: [PATCH] Generate identifier when creating the database, not on update This fixes the broken 'setLogin' when using Lychee for the first time. --- php/database/update_030001.php | 8 -------- php/modules/Database.php | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/php/database/update_030001.php b/php/database/update_030001.php index 24a0191..3147255 100644 --- a/php/database/update_030001.php +++ b/php/database/update_030001.php @@ -54,14 +54,6 @@ if ($result->num_rows===0) { Log::error($database, 'update_030001', __LINE__, 'Could not update database (' . $database->error . ')'); return false; } -} else { - $identifier = md5(microtime(true)); - $query = Database::prepare($database, "UPDATE `?` SET `value` = '?' WHERE `key` = 'identifier' LIMIT 1", array(LYCHEE_TABLE_SETTINGS, $identifier)); - $result = $database->query($query); - if (!$result) { - Log::error($database, 'update_030001', __LINE__, 'Could not reset public albums (' . $database->error . ')'); - return false; - } } # Set version diff --git a/php/modules/Database.php b/php/modules/Database.php index 13bcff7..280de73 100755 --- a/php/modules/Database.php +++ b/php/modules/Database.php @@ -198,6 +198,14 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); return false; } + # Generate identifier + $identifier = md5(microtime(true)); + $query = Database::prepare($database, "UPDATE `?` SET `value` = '?' WHERE `key` = 'identifier' LIMIT 1", array(LYCHEE_TABLE_SETTINGS, $identifier)); + if (!$database->query($query)) { + Log::error($database, __METHOD__, __LINE__, $database->error); + return false; + } + } # Create albums