Browse Source

Generate identifier when creating the database, not on update

This fixes the broken 'setLogin' when using Lychee for the first time.
Tobias Reich 8 years ago
parent
commit
f925e118c2
2 changed files with 8 additions and 8 deletions
  1. 0 8
      php/database/update_030001.php
  2. 8 0
      php/modules/Database.php

+ 0 - 8
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

+ 8 - 0
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