Created attachment 48852 [details] [review] Bug 16015: Restore the ability to delete a group of libraries If a group of libraries is linked to at least 1 library, the group cannot be delete and the librarian should get a warning message. But if no libraries are linked, the deletion should be allowed. Since bug 15294 this behavior is broken: The deletion is always blocked: "This library category cannot be deleted. 0 libraries are still using it", hum... Test plan: Create a group of libraries, delete it
This is totally weird. It must be that $libraries_count gets interpreted as "0". Perl, I did not expect that from you. Anyway, although this patch does solve the issue, pedantic devil in me says - wait. The way it is written says my $libraries_count = (scalar( $category->libraries ) > 0) which does yield correct boolean, but evaluates to 1 no matter how many libraries are there. Correct way could be my $libraries_count = scalar( $category->libraries ) + 0 or (my $libraries_count = scalar( $category->libraries )) > 0
(In reply to Srdjan Jankovic from comment #2) > This is totally weird. It must be that $libraries_count gets interpreted as > "0". Perl, I did not expect that from you. > Anyway, although this patch does solve the issue, pedantic devil in me says > - wait. > The way it is written says > my $libraries_count = (scalar( $category->libraries ) > 0) > which does yield correct boolean, but evaluates to 1 no matter how many > libraries are there. > Correct way could be > my $libraries_count = scalar( $category->libraries ) + 0 > or > (my $libraries_count = scalar( $category->libraries )) > 0 Do not worry, what you read is confusing :) $category->libraries returns, in an array context, an array of DBIx::Class objects. But, in a scalar context, an ... iterator. So it's always defined. I will submit a patch to clarify the changes and avoid any confusions later.
Created attachment 48990 [details] [review] Bug 16015: Restore the ability to delete a group of libraries If a group of libraries is linked to at least 1 library, the group cannot be delete and the librarian should get a warning message. But if no libraries are linked, the deletion should be allowed. Since bug 15294 this behavior is broken: The deletion is always blocked: "This library category cannot be deleted. 0 libraries are still using it", hum... Test plan: Create a group of libraries, delete it
+ if ( my $libraries_count = $category->libraries->count ) { is definitely the way to do :)
Created attachment 49079 [details] [review] [SIGNED-OFF] Bug 16015: Restore the ability to delete a group of libraries If a group of libraries is linked to at least 1 library, the group cannot be delete and the librarian should get a warning message. But if no libraries are linked, the deletion should be allowed. Since bug 15294 this behavior is broken: The deletion is always blocked: "This library category cannot be deleted. 0 libraries are still using it", hum... Test plan: Create a group of libraries, delete it Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
*** Bug 16091 has been marked as a duplicate of this bug. ***
Raising the severity as it's a regression.
The patch fixes the problem, but the error/message dialogs are not looking quite right (maybe something for Owen/Aleisha :) ) Are you sure you want to delete the group '' (TEST)?
Created attachment 49331 [details] [review] [PASSED QA] Bug 16015: Restore the ability to delete a group of libraries If a group of libraries is linked to at least 1 library, the group cannot be delete and the librarian should get a warning message. But if no libraries are linked, the deletion should be allowed. Since bug 15294 this behavior is broken: The deletion is always blocked: "This library category cannot be deleted. 0 libraries are still using it", hum... Test plan: Create a group of libraries, delete it Signed-off-by: Srdjan <srdjan@catalyst.net.nz> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to Master - Should be in the May 2016 release. Thanks!
Does not concern stable versions, status changed to RESOLVED