Bugzilla – Attachment 180828 Details for
Bug 23990
Move C4::Suggestions code to the Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23990: Remove GetSuggestionInfoFromBiblionumber from C4/Suggestions.pm
Bug-23990-Remove-GetSuggestionInfoFromBiblionumber.patch (text/plain), 8.73 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-04-11 10:51:15 UTC
(
hide
)
Description:
Bug 23990: Remove GetSuggestionInfoFromBiblionumber from C4/Suggestions.pm
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-04-11 10:51:15 UTC
Size:
8.73 KB
patch
obsolete
>From 530339316490c3617de8d54f6f8ab2669197a496 Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Tue, 8 Apr 2025 14:30:34 +0200 >Subject: [PATCH] Bug 23990: Remove GetSuggestionInfoFromBiblionumber from > C4/Suggestions.pm > >--- > C4/Suggestions.pm | 28 -------------------- > acqui/basket.pl | 10 +++---- > acqui/orderreceive.pl | 10 +------ > acqui/parcel.pl | 7 +++-- > t/db_dependent/Suggestions.t | 51 ++---------------------------------- > 5 files changed, 11 insertions(+), 95 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index f2999f02..2abd8dec 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -35,7 +35,6 @@ our @EXPORT = qw( > ConnectSuggestionAndBiblio > DelSuggestion > GetSuggestionByStatus >- GetSuggestionInfoFromBiblionumber > GetSuggestionInfo > ModStatus > ModSuggestion >@@ -69,33 +68,6 @@ Suggestions done by other borrowers can be seen when not "AVAILABLE" > > =head1 FUNCTIONS > >-=head2 GetSuggestionInfoFromBiblionumber >- >-Get a suggestion and borrower's informations from it's biblionumber. >- >-return : >-all informations (suggestion and borrower) of the suggestion which is related to the biblionumber given. >- >-=cut >- >-sub GetSuggestionInfoFromBiblionumber { >- my ($biblionumber) = @_; >- my $query = q{ >- SELECT suggestions.*, >- U1.surname AS surnamesuggestedby, >- U1.firstname AS firstnamesuggestedby, >- U1.borrowernumber AS borrnumsuggestedby >- FROM suggestions >- LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber >- WHERE biblionumber=? >- LIMIT 1 >- }; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare($query); >- $sth->execute($biblionumber); >- return $sth->fetchrow_hashref; >-} >- > =head2 GetSuggestionInfo > > Get a suggestion and borrower's informations from it's suggestionid >diff --git a/acqui/basket.pl b/acqui/basket.pl >index fad4152c..10de07ea 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -28,7 +28,7 @@ use C4::Acquisition > qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price ); > use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); > use C4::Contract qw( GetContract ); >-use C4::Suggestions qw( GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); >+use C4::Suggestions qw( GetSuggestionInfo ); > use Koha::Biblios; > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Booksellers; >@@ -544,10 +544,10 @@ sub get_order_infos { > $line{deleted_biblio} = Koha::Old::Biblios->find( $order->{deleted_biblionumber} ); > } > >- my $suggestion = GetSuggestionInfoFromBiblionumber( $line{biblionumber} ); >- $line{suggestionid} = $$suggestion{suggestionid}; >- $line{surnamesuggestedby} = $$suggestion{surnamesuggestedby}; >- $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby}; >+ my $suggestion = Koha::Suggestions->find( { biblionumber => $line{biblionumber} } ); >+ $line{suggestionid} = $suggestion->{suggestionid}; >+ $line{surnamesuggestedby} = $suggestion->suggester->surname; >+ $line{firstnamesuggestedby} = $suggestion->suggester->firstname; > > $line{estimated_delivery_date} = $order->{estimated_delivery_date}; > >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 1874eb7e..119ec2ca 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -66,9 +66,7 @@ use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Budgets qw( GetBudget GetBudgetPeriods GetBudgetPeriod GetBudgetHierarchy CanUserUseBudget ); > use C4::Members; >-use C4::Biblio qw( GetMarcStructure ); >-use C4::Suggestions qw( GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); >- >+use C4::Biblio qw( GetMarcStructure ); > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Currencies qw( get_active ); > use Koha::Acquisition::Orders; >@@ -133,12 +131,6 @@ if ($order) { > $template->param( orders => $orders, ); > } > >- my $suggestion = GetSuggestionInfoFromBiblionumber( $order->biblionumber ); >- >- if ($suggestion) { >- $template->param( suggestion => $suggestion ); >- } >- > $template->param( > order => $order, > creator => $creator, >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index a53aba06..599320ed 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -60,7 +60,6 @@ use C4::Acquisition qw( CancelReceipt GetInvoice GetInvoiceDetails get_rounded_p > use C4::Budgets qw( GetBudget GetBudgetByOrderNumber GetBudgetName ); > use CGI qw ( -utf8 ); > use C4::Output qw( output_html_with_http_headers ); >-use C4::Suggestions qw( GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); > > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Bookseller; >@@ -150,10 +149,10 @@ for my $order (@orders) { > $total_tax_excluded += get_rounded_price( $line{unitprice_tax_excluded} ) * $line{quantity}; > $total_tax_included += get_rounded_price( $line{unitprice_tax_included} ) * $line{quantity}; > >- my $suggestion = GetSuggestionInfoFromBiblionumber( $line{biblionumber} ); >+ my $suggestion = Koha::Suggestions->find( { biblionumber => $line{biblionumber} } ); > $line{suggestionid} = $suggestion->{suggestionid}; >- $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; >- $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; >+ $line{surnamesuggestedby} = $suggestion->suggester->surname; >+ $line{firstnamesuggestedby} = $suggestion->suggester->firstname; > > if ( $line{parent_ordernumber} != $line{ordernumber} ) { > if ( grep { $_->{ordernumber} == $line{parent_ordernumber} } @orders ) { >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 50591c7a..693c0b4b 100755 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use DateTime::Duration; > use Test::NoWarnings; >-use Test::More tests => 92; >+use Test::More tests => 80; > use Test::Warn; > > use t::lib::Mocks; >@@ -38,7 +38,7 @@ use Koha::Suggestions; > BEGIN { > use_ok( > 'C4::Suggestions', >- qw( ModSuggestion GetSuggestionInfo GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) >+ qw( ModSuggestion GetSuggestionInfo GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) > ); > } > >@@ -335,53 +335,6 @@ is( > 'GetSuggestionInfo returns the borrower number correctly' > ); > >-is( >- GetSuggestionInfoFromBiblionumber(), undef, >- 'GetSuggestionInfoFromBiblionumber without the biblio number returns undef' >-); >-is( >- GetSuggestionInfoFromBiblionumber(2), undef, >- 'GetSuggestionInfoFromBiblionumber with an invalid biblio number returns undef' >-); >-$suggestion = GetSuggestionInfoFromBiblionumber( $biblio_1->biblionumber ); >-is( >- $suggestion->{suggestionid}, $my_suggestionid, >- 'GetSuggestionInfoFromBiblionumber returns the suggestion id correctly' >-); >-is( $suggestion->{title}, $mod_suggestion1->{title}, 'GetSuggestionInfoFromBiblionumber returns the title correctly' ); >-is( >- $suggestion->{author}, $mod_suggestion1->{author}, >- 'GetSuggestionInfoFromBiblionumber returns the author correctly' >-); >-is( >- $suggestion->{publishercode}, $mod_suggestion1->{publishercode}, >- 'GetSuggestionInfoFromBiblionumber returns the publisher code correctly' >-); >-is( >- $suggestion->{suggestedby}, $my_suggestion->{suggestedby}, >- 'GetSuggestionInfoFromBiblionumber returns the borrower number correctly' >-); >-is( >- $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, >- 'GetSuggestionInfoFromBiblionumber returns the biblio number correctly' >-); >-is( >- $suggestion->{STATUS}, $mod_suggestion3->{STATUS}, >- 'GetSuggestionInfoFromBiblionumber returns the status correctly' >-); >-is( >- $suggestion->{surnamesuggestedby}, $member->{surname}, >- 'GetSuggestionInfoFromBiblionumber returns the surname correctly' >-); >-is( >- $suggestion->{firstnamesuggestedby}, $member->{firstname}, >- 'GetSuggestionInfoFromBiblionumber returns the firstname correctly' >-); >-is( >- $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, >- 'GetSuggestionInfoFromBiblionumeber returns the borrower number correctly' >-); >- > my $suggestions = GetSuggestionByStatus(); > is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' ); > $suggestions = GetSuggestionByStatus('CHECKED'); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23990
:
180826
|
180827
| 180828 |
180829
|
180830
|
180831
|
180832
|
180833
|
180834
|
180835
|
180836
|
180837