Bugzilla – Attachment 80670 Details for
Bug 21556
Deleting same record twice leads to fatal software error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21556: Do not crash if a biblio is deleted twice
Bug-21556-Do-not-crash-if-a-biblio-is-deleted-twic.patch (text/plain), 2.55 KB, created by
Jonathan Druart
on 2018-10-16 17:54:47 UTC
(
hide
)
Description:
Bug 21556: Do not crash if a biblio is deleted twice
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-10-16 17:54:47 UTC
Size:
2.55 KB
patch
obsolete
>From ddf15dc35ef5cd0dfbaebc0c45762659e3022bb7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Oct 2018 14:52:25 -0300 >Subject: [PATCH] Bug 21556: Do not crash if a biblio is deleted twice > >To recreate: >- Go to a bibliographic detail page >- Delete it >- Go back >- Delete it again >=> Without this patch you will get a 500 > Can't call method "holds" on an undefined value at > /home/vagrant/kohaclone/C4/Biblio.pm line 406. >=> With this patch applied it will silently redirect you to the search >form. > >Note: We could/should improve the behavior and display a message, but >DelBiblio will need to be moved to Koha::Biblio->delete and other >callers adjusted >--- > C4/Biblio.pm | 5 ++++- > t/db_dependent/Biblio.t | 13 ++++++++++++- > 2 files changed, 16 insertions(+), 2 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 50c7c4cc10..e58e19cd7e 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -361,6 +361,10 @@ C<$error> : undef unless an error occurs > > sub DelBiblio { > my ($biblionumber) = @_; >+ >+ my $biblio = Koha::Biblios->find( $biblionumber ); >+ return unless $biblio; # Should we throw an exception instead? >+ > my $dbh = C4::Context->dbh; > my $error; # for error handling > >@@ -383,7 +387,6 @@ sub DelBiblio { > } > > # We delete any existing holds >- my $biblio = Koha::Biblios->find( $biblionumber ); > my $holds = $biblio->holds; > while ( my $hold = $holds->next ) { > $hold->cancel; >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index bb43bb1dd0..b5dd7ea60e 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 10; > use Test::MockModule; > use List::MoreUtils qw( uniq ); > use MARC::Record; >@@ -455,6 +455,17 @@ subtest 'deletedbiblio_metadata' => sub { > is( $moved, $biblionumber, 'Found in deletedbiblio_metadata' ); > }; > >+subtest 'DelBiblio' => sub { >+ plan tests => 2; >+ >+ my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, ''); >+ my $deleted = C4::Biblio::DelBiblio( $biblionumber ); >+ is( $deleted, undef, 'DelBiblio returns undef is the biblio has been deleted correctly - Must be 1 instead'); # FIXME We should return 1 instead! >+ >+ $deleted = C4::Biblio::DelBiblio( $biblionumber ); >+ is( $deleted, undef, 'DelBiblo should return undef is the record did not exist'); >+}; >+ > # Cleanup > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > $schema->storage->txn_rollback; >-- >2.11.0
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 21556
:
80442
|
80559
|
80560
|
80670
|
80685
|
81813
|
81814