Added update for database for version 2.6.2
This commit is contained in:
parent
864e5b97d0
commit
8b4ef96146
36
php/database/update_020602.php
Normal file
36
php/database/update_020602.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
###
|
||||
# @name Update to version 2.6.2
|
||||
# @author Tobias Reich
|
||||
# @copyright 2014 by Tobias Reich
|
||||
###
|
||||
|
||||
# Add a checksum
|
||||
$result = $database->query("SELECT `id`, `url` FROM `lychee_photos` WHERE `checksum` IS NULL;");
|
||||
if (!$result) {
|
||||
Log::error($database, 'update_020602', __LINE__, 'Could not find photos without checksum (' . $database->error . ')');
|
||||
return false;
|
||||
}
|
||||
while ($photo = $result->fetch_object()) {
|
||||
$checksum = sha1_file(LYCHEE_UPLOADS_BIG . $photo->url);
|
||||
if ($checksum!==false) {
|
||||
$setChecksum = $database->query("UPDATE `lychee_photos` SET `checksum` = '$checksum' WHERE `id` = '$photo->id';");
|
||||
if (!$setChecksum) {
|
||||
Log::error($database, 'update_020602', __LINE__, 'Could not update checksum (' . $database->error . ')');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Log::error($database, 'update_020602', __LINE__, 'Could not calculate checksum for photo with id ' . $photo->id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
# Set version
|
||||
$result = $database->query("UPDATE lychee_settings SET value = '020602' WHERE `key` = 'version';");
|
||||
if (!$result) {
|
||||
Log::error($database, 'update_020602', __LINE__, 'Could not update database (' . $database->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
@ -48,7 +48,8 @@ class Database extends Module {
|
||||
'020200', #2.2
|
||||
'020500', #2.5
|
||||
'020505', #2.5.5
|
||||
'020601' #2.6.1
|
||||
'020601', #2.6.1
|
||||
'020602' #2.6.2
|
||||
);
|
||||
|
||||
# For each update
|
||||
|
@ -103,6 +103,10 @@ class Photo extends Module {
|
||||
|
||||
# Calculate checksum
|
||||
$checksum = sha1_file($tmp_name);
|
||||
if ($checksum===false) {
|
||||
Log::error($this->database, __METHOD__, __LINE__, 'Could not calculate checksum for photo');
|
||||
exit('Error: Could not calculate checksum for photo!');
|
||||
}
|
||||
|
||||
# Check if image exists based on checksum
|
||||
if ($checksum===false) {
|
||||
|
Loading…
Reference in New Issue
Block a user