@@ -, +, @@ --- installer/data/mysql/atomicupdate/bug_29778.pl | 18 ++++++++++++++++++ tools/additional-contents.pl | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29778.pl --- a/installer/data/mysql/atomicupdate/bug_29778.pl +++ a/installer/data/mysql/atomicupdate/bug_29778.pl @@ -0,0 +1,18 @@ +use Modern::Perl; + +return { + bug_number => "29778", + description => "Delete orphan additional contents", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + DELETE FROM additional_contents + WHERE code NOT IN ( + SELECT code + FROM additional_contents + WHERE lang = "default" + ); + }); + }, +} --- a/tools/additional-contents.pl +++ a/tools/additional-contents.pl @@ -204,12 +204,12 @@ elsif ( $op eq 'delete_confirmed' ) { my $contents = Koha::AdditionalContents->search( { idnew => \@ids } ); - if ( C4::Context->preference("NewsLog") ) { - while ( my $c = $contents->next ) { + while ( my $c = $contents->next ) { + Koha::AdditionalContents->search( { code => $c->code } )->delete; + if ( C4::Context->preference("NewsLog") ) { logaction('NEWS', 'DELETE' , undef, sprintf("%s|%s|%s|%s", $c->code, $c->title, $c->lang, $c->content)); } } - $contents->delete; } ); }; --