Skip to content

Commit

Permalink
Fixed: no error message when rotate fails
Browse files Browse the repository at this point in the history
Closes #33
  • Loading branch information
jeroenrnl committed Sep 26, 2012
1 parent cba007b commit 16d9a65
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
7 changes: 6 additions & 1 deletion php/edit_photos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions php/exception.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
12 changes: 5 additions & 7 deletions php/photo.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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));
}

}
Expand All @@ -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;
}

/*
Expand Down
7 changes: 6 additions & 1 deletion php/photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 16d9a65

Please sign in to comment.