From 9d46c378b9cb7abe78958c087912e5533d1f2144 Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sat, 22 Oct 2011 11:01:06 +0200 Subject: [PATCH] Fix unescessary use of non portable 'replace' sql and add loging when GD not installed --- apps/gallery/ajax/thumbnail.php | 3 +++ apps/gallery/lib_scanner.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php index f24782390f..325adb46bd 100644 --- a/apps/gallery/ajax/thumbnail.php +++ b/apps/gallery/ajax/thumbnail.php @@ -5,6 +5,9 @@ OC_JSON::checkAppEnabled('gallery'); function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. //getting the image dimensions + if(! function_exists('imagecreatefromjpeg')) + OC_Log::write('gallery','GD module not installed',OC_Log::ERROR); + list($width_orig, $height_orig) = getimagesize($imgSrc); switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) { case "jpeg": diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib_scanner.php index 5490c4a55a..1231de3f3c 100644 --- a/apps/gallery/lib_scanner.php +++ b/apps/gallery/lib_scanner.php @@ -31,7 +31,7 @@ class OC_GALLERY_SCANNER { $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?'); $result = $stmt->execute(array(OC_User::getUser(), $current_album['name'])); if ($result->numRows() == 0 && count($current_album['images'])) { - $stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_albums (`uid_owner`, `album_name`) VALUES (?, ?)'); + $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (`uid_owner`, `album_name`) VALUES (?, ?)'); $stmt->execute(array(OC_User::getUser(), $current_album['name'])); } $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?'); @@ -42,7 +42,7 @@ class OC_GALLERY_SCANNER { $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ? AND `file_path` = ?'); $result = $stmt->execute(array($albumId, $img)); if ($result->numRows() == 0) { - $stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)'); + $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)'); $stmt->execute(array($albumId, $img)); } }