If you try to upload an image into Patron Card Creator with the same file name as an image that has already been upload, the original image gets replaced, without any warning. There should be some kind of warning before replacing, i.e. "The name "filename" already exists. Upload and replace image or cancel upload?"
Created attachment 58789 [details] [review] Bug 17181: Check for duplicate image names when uploading image to patron card creator This patch adds a check for duplicates before uploading the image. To test: 1) Go to Tools -> Patron card creator -> Manage images 2) If you haven't already, upload an image 3) Try to upload another image with the same image name 4) Notice the first image is replaced with the second image, with no warning. 5) Apply patch and refresh page 6) Try to upload an image with the same image name again 7) Notice you are now warned about a duplicate image name. 8) Check that uploading an image with a unique name still works. Sponsored-by: Catalyst IT
Created attachment 58808 [details] [review] Bug 17181: Check for duplicate image names when uploading image to patron card creator This patch adds a check for duplicates before uploading the image. To test: 1) Go to Tools -> Patron card creator -> Manage images 2) If you haven't already, upload an image 3) Try to upload another image with the same image name 4) Notice the first image is replaced with the second image, with no warning. 5) Apply patch and refresh page 6) Try to upload an image with the same image name again 7) Notice you are now warned about a duplicate image name. 8) Check that uploading an image with a unique name still works. Sponsored-by: Catalyst IT Signed-off-by: Claire Gravely <claire_gravely@hotmail.com>
Comment on attachment 58808 [details] [review] Bug 17181: Check for duplicate image names when uploading image to patron card creator Review of attachment 58808 [details] [review]: ----------------------------------------------------------------- ::: patroncards/image-manage.pl @@ +49,5 @@ > if ($op eq 'upload') { > + # Checking for duplicate image name > + my $duplicate; > + my $dbh = C4::Context->dbh; > + my $query = "SELECT image_name FROM creator_images"; What you want here is to select the number of images with the $image_name: SELECT COUNT(*) FROM creator_images WHERE image_name=? That will simplify this part of code.
Created attachment 58888 [details] [review] Bug 17181: Check for duplicate image names when uploading image to patron card creator This patch adds a check for duplicates before uploading the image. To test: 1) Go to Tools -> Patron card creator -> Manage images 2) If you haven't already, upload an image 3) Try to upload another image with the same image name 4) Notice the first image is replaced with the second image, with no warning. 5) Apply patch and refresh page 6) Try to upload an image with the same image name again 7) Notice you are now warned about a duplicate image name. 8) Check that uploading an image with a unique name still works. Sponsored-by: Catalyst IT Signed-off-by: Claire Gravely <claire_gravely@hotmail.com>
Created attachment 58917 [details] [review] Bug 17181: Check for duplicate image names when uploading image to patron card creator This patch adds a check for duplicates before uploading the image. To test: 1) Go to Tools -> Patron card creator -> Manage images 2) If you haven't already, upload an image 3) Try to upload another image with the same image name 4) Notice the first image is replaced with the second image, with no warning. 5) Apply patch and refresh page 6) Try to upload an image with the same image name again 7) Notice you are now warned about a duplicate image name. 8) Check that uploading an image with a unique name still works. Sponsored-by: Catalyst IT Signed-off-by: Claire Gravely <claire_gravely@hotmail.com>
Created attachment 58921 [details] [review] Bug 17181: Check for duplicate image names when uploading image to patron card creator This patch adds a check for duplicates before uploading the image. To test: 1) Go to Tools -> Patron card creator -> Manage images 2) If you haven't already, upload an image 3) Try to upload another image with the same image name 4) Notice the first image is replaced with the second image, with no warning. 5) Apply patch and refresh page 6) Try to upload an image with the same image name again 7) Notice you are now warned about a duplicate image name. 8) Check that uploading an image with a unique name still works. Sponsored-by: Catalyst IT Signed-off-by: Claire Gravely <claire_gravely@hotmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 58922 [details] [review] Bug 17181: Simplify code - do not prepare statement when used only once - remove use of Data::Dumper - remove $duplicate, not needed Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Pushed to master for 17.05, thanks Aleisha, Jonathan!
This won't get ported back to 16.11.x as it is an enhancement.
*** Bug 15000 has been marked as a duplicate of this bug. ***
(In reply to Katrin Fischer from comment #9) > This won't get ported back to 16.11.x as it is an enhancement. Hi Katrin, can you reconsider, since users can run into a data loss by overwriting images? Marc
These patches have been pushed to 16.11.x and will be in 16.11.10.
Pushed to 16.05.x, for 16.05.15 release