Bug 16819

Summary: C4::Members::DelMember should use Koha::Holds to delete holds
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: f.demians, hector.hecaxmmx, jonathan.druart, kyle, veron
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 14642    
Attachments: Bug 16819: Unit tests for C4::Members::DelMember
Bug 16819: C4::Members::DelMember should use Koha::Holds to delete holds
[SIGNED-OFF]Bug 16819: Unit tests for C4::Members::DelMember
[SIGNED-OFF]Bug 16819: C4::Members::DelMember should use Koha::Holds to delete holds
Bug 16819: Unit tests for C4::Members::DelMember
Bug 16819: C4::Members::DelMember should use Koha::Holds to delete holds
Bug 16819: Remove use of map

Description Tomás Cohen Arazi 2016-06-27 18:02:42 UTC

    
Comment 1 Tomás Cohen Arazi 2016-06-28 14:08:39 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi 2016-06-28 14:08:44 UTC Comment hidden (obsolete)
Comment 3 Héctor Eduardo Castro Avalos 2016-07-01 15:17:32 UTC Comment hidden (obsolete)
Comment 4 Héctor Eduardo Castro Avalos 2016-07-01 15:17:43 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2016-07-01 16:11:00 UTC
Comment on attachment 53031 [details] [review]
[SIGNED-OFF]Bug 16819: C4::Members::DelMember should use Koha::Holds to delete holds

Review of attachment 53031 [details] [review]:
-----------------------------------------------------------------

::: C4/Members.pm
@@ +1662,5 @@
>      #warn "in delmember with $borrowernumber";
>      return unless $borrowernumber;    # borrowernumber is mandatory.
> +    # Delete Patron's holds
> +    my @holds = Koha::Holds->search({ borrowernumber => $borrowernumber });
> +    map { $_->delete } @holds;

I'd have written that `$_->delete for @holds`. Since map is supposed to return something I guess it can perturb a new developer. Do you agree?
Comment 6 Jonathan Druart 2016-07-03 14:59:50 UTC
Created attachment 53054 [details] [review]
Bug 16819: Unit tests for C4::Members::DelMember

The C4::Members::DelMember function actually deletes reserves, and it is
not properly tested.

To test:
- Apply the patch
- Run:
  $ prove  t/db_dependent/Members.t
=> SUCCESS: Tests pass
- Sign off

Sponsored-by: NEKLS
Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Jonathan Druart 2016-07-03 15:00:00 UTC
Created attachment 53055 [details] [review]
Bug 16819: C4::Members::DelMember should use Koha::Holds to delete holds

This patch makes C4::Members::DelMember proprely use Koha::Holds to delete
holds. This is important as holds actions are started to be logged.

To reproduce:
- Apply the patch
- Run:
  $ prove t/db_dependent/Members.t
=> SUCCESS: Tests pass
- Sign off :-D

Sponsored-by: NEKLS
Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
All tests pass successfully

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Jonathan Druart 2016-07-03 15:00:10 UTC
Created attachment 53056 [details] [review]
Bug 16819: Remove use of map

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Jonathan Druart 2016-07-03 15:01:08 UTC
(In reply to Jonathan Druart from comment #8)
> Created attachment 53056 [details] [review] [review]
> Bug 16819: Remove use of map
> 
> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Tomas or RM: feel free to obsolete this patch if you want to.
Comment 10 Tomás Cohen Arazi 2016-07-06 11:07:10 UTC
(In reply to Jonathan Druart from comment #9)
> (In reply to Jonathan Druart from comment #8)
> > Created attachment 53056 [details] [review] [review] [review]
> > Bug 16819: Remove use of map
> > 
> > Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
> 
> Tomas or RM: feel free to obsolete this patch if you want to.

I like either, passing the ball to the RM :-D
Comment 11 Kyle M Hall 2016-07-08 14:49:36 UTC
Pushed to master for 16.11, thanks Tomas, Jonathan!
Comment 12 Frédéric Demians 2016-08-01 13:36:23 UTC
Pushed in 16.05. Will be in 16.05.02.