Bug 40919 - Unnecessary DB access in Koha::Item::Transfer->receive
Summary: Unnecessary DB access in Koha::Item::Transfer->receive
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 25767
Blocks:
  Show dependency treegraph
 
Reported: 2025-09-30 22:24 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2025-12-01 19:55 UTC (History)
2 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:


Attachments
Bug 40919: Remove unnecessary DB call in Koha::Item::Transfer->receive (1.10 KB, patch)
2025-09-30 22:29 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 40919: Remove unnecessary DB call in Koha::Item::Transfer->receive (1.17 KB, patch)
2025-11-18 17:14 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2025-09-30 22:24:17 UTC
This line:

```perl
    ModDateLastSeen( $self->item->itemnumber );
```

could just be

```perl
    ModDateLastSeen( $self->itemnumber );
```

There's no need to instantiate the related Koha::Item object.
Comment 1 Tomás Cohen Arazi (tcohen) 2025-09-30 22:29:45 UTC
Created attachment 187143 [details] [review]
Bug 40919: Remove unnecessary DB call in Koha::Item::Transfer->receive

This patch removes a trivially not required DB object instantiation.
This implies saving CPU usage for the instantiation and algo for
fetching from the DB.

To test:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Item/Transfer.t
=> SUCCESS: Tests pass! They cover ->receive()
2. Apply this patch
3. Repeat 1
=> SUCCESS: No behavior change, tests pass!
4. Sign off :-D
Comment 2 Martin Renvoize (ashimema) 2025-11-18 17:14:53 UTC
Created attachment 189675 [details] [review]
Bug 40919: Remove unnecessary DB call in Koha::Item::Transfer->receive

This patch removes a trivially not required DB object instantiation.
This implies saving CPU usage for the instantiation and algo for
fetching from the DB.

To test:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Item/Transfer.t
=> SUCCESS: Tests pass! They cover ->receive()
2. Apply this patch
3. Repeat 1
=> SUCCESS: No behavior change, tests pass!
4. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 3 Lucas Gass (lukeg) 2025-12-01 19:55:20 UTC
Nice work everyone!

Pushed to main for 25.11