From 99cfb11d9e65db39ce45c365f940adb2ac0e0f7a Mon Sep 17 00:00:00 2001
From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Date: Tue, 8 Apr 2025 15:44:16 +0200
Subject: [PATCH] Bug 39726: Remove ConnectSuggestionAndBiblio from
 C4/Suggestions.pm

To test:
Create a suggestion whose isbn fits an existing one (note: you must have
        a working search engine)
---
 C4/Suggestions.pm            | 21 ---------------------
 acqui/newordersuggestion.pl  |  7 +++----
 t/db_dependent/Suggestions.t | 14 +++-----------
 3 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm
index 6d444d3b..d22ca13a 100644
--- a/C4/Suggestions.pm
+++ b/C4/Suggestions.pm
@@ -32,7 +32,6 @@ use C4::Log qw(logaction);
 use base qw(Exporter);
 
 our @EXPORT = qw(
-    ConnectSuggestionAndBiblio
     DelSuggestion
     ModStatus
     ModSuggestion
@@ -137,26 +136,6 @@ sub ModSuggestion {
     return 1;    # No useful if the exception is raised earlier
 }
 
-=head2 ConnectSuggestionAndBiblio
-
-&ConnectSuggestionAndBiblio($ordernumber,$biblionumber)
-
-connect a suggestion to an existing biblio
-
-=cut
-
-sub ConnectSuggestionAndBiblio {
-    my ( $suggestionid, $biblionumber ) = @_;
-    my $dbh   = C4::Context->dbh;
-    my $query = q{
-        UPDATE suggestions
-        SET    biblionumber=?
-        WHERE  suggestionid=?
-    };
-    my $sth = $dbh->prepare($query);
-    $sth->execute( $biblionumber, $suggestionid );
-}
-
 =head2 DelSuggestion
 
 &DelSuggestion($borrowernumber,$ordernumber)
diff --git a/acqui/newordersuggestion.pl b/acqui/newordersuggestion.pl
index 180af5a3..fe09463b 100755
--- a/acqui/newordersuggestion.pl
+++ b/acqui/newordersuggestion.pl
@@ -81,10 +81,9 @@ the id of the suggestion to select.
 
 use Modern::Perl;
 
-use CGI             qw ( -utf8 );
-use C4::Auth        qw( get_template_and_user );
-use C4::Output      qw( output_html_with_http_headers );
-use C4::Suggestions qw( ConnectSuggestionAndBiblio );
+use CGI        qw ( -utf8 );
+use C4::Auth   qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
 use C4::Budgets;
 
 use Koha::Acquisition::Booksellers;
diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t
index 33b4ffb3..10b9123a 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 => 55;
+use Test::More tests => 52;
 use Test::Warn;
 
 use t::lib::Mocks;
@@ -38,7 +38,7 @@ use Koha::Suggestions;
 BEGIN {
     use_ok(
         'C4::Suggestions',
-        qw( ModSuggestion ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
+        qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
     );
 }
 
@@ -310,15 +310,7 @@ $messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber2
 
 is( scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error' );
 
-is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arguments returns 0E0' );
-my $biblio_2                      = $builder->build_object( { class => 'Koha::Biblios' } );
-my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio( $my_suggestionid, $biblio_2->biblionumber );
-is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' );
-$suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed();
-is(
-    $suggestion->{biblionumber}, $biblio_2->biblionumber,
-    'ConnectSuggestionAndBiblio updates the biblio number correctly'
-);
+my $biblio_2 = $builder->build_object( { class => 'Koha::Biblios' } );
 
 my $del_suggestion = {
     title       => 'my deleted title',
-- 
2.30.2