Permalink
Browse files

Fixed: no error message when rotate fails

Closes #33
  • Loading branch information...
1 parent cba007b commit 16d9a65f67aa966bfda1e0617b6e766da12499bd @jeroenrnl committed Sep 26, 2012
Showing with 18 additions and 9 deletions.
  1. +6 −1 php/edit_photos.php
  2. +1 −0 php/exception.inc.php
  3. +5 −7 php/photo.inc.php
  4. +6 −1 php/photo.php
View
7 php/edit_photos.php
@@ -206,7 +206,12 @@
$deg = $request_vars["_deg__$photo_id"];
if ($deg && $deg != 0) {
$photo->lookupForUser($user);
- $photo->rotate($deg);
+ try {
+ $photo->rotate($deg);
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ die;
+ }
}
}
else if ($can_edit && $action == 'delete') {
View
1 php/exception.inc.php
@@ -44,6 +44,7 @@ class FileNotReadableException extends FileException {}
class FileNotWritableException extends FileException {}
class FileMoveFailedException extends FileException {}
class FileCopyFailedException extends FileException {}
+class FileRenameException extends FileException {}
class FileSymlinkProblemException extends FileException {}
class PhotoException extends ZophException {}
View
12 php/photo.inc.php
@@ -814,7 +814,8 @@ function rotate($deg) {
// is always preserved.
if (!file_exists($dir . $backup_name)) {
if (!copy($dir . $name, $dir . $backup_name)) {
- echo sprintf(translate("Could not copy %s to %s."), $name, $backup_name) . "<br>\n";
+ throw new FileCopyFailedException(
+ sprintf(translate("Could not copy %s to %s."), $name, $backup_name));
return;
}
}
@@ -860,13 +861,12 @@ function) doesn't write it into the exported image file.
$output = system($cmd);
if ($output) { // error
- echo translate("An error occurred.") . " $output<br>\n";
- continue; // or return;
+ throw new ZophException(translate("An error occurred. ") . $output);
}
if (!rename($tmp_file, $file)) {
- echo sprintf(translate("Could not rename %s to %s."), $tmp_file, $file) . "<br>\n";
- continue; // or return;
+ throw new FileRenameException(
+ sprintf(translate("Could not rename %s to %s."), $tmp_file, $file));
}
}
@@ -875,8 +875,6 @@ function) doesn't write it into the exported image file.
// (only if original was rotated)
$this->update();
$this->updateSize();
-
- return 1;
}
/*
View
7 php/photo.php
@@ -137,7 +137,12 @@
if ($_deg && $_deg != 0) {
if (ALLOW_ROTATIONS) {
$photo->lookup();
- $photo->rotate($_deg);
+ try {
+ $photo->rotate($_deg);
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ die;
+ }
}
} else if ($_thumbnail) {
// thumbnails already recreated for rotations

0 comments on commit 16d9a65

Please sign in to comment.