Bugzilla – Attachment 129040 Details for
Bug 29778
Deleting additional_contents leaves entries for additional languages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29778: Prevent orphan additional contents
Bug-29778-Prevent-orphan-additional-contents.patch (text/plain), 2.72 KB, created by
Lucas Gass (lukeg)
on 2022-01-05 18:19:08 UTC
(
hide
)
Description:
Bug 29778: Prevent orphan additional contents
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2022-01-05 18:19:08 UTC
Size:
2.72 KB
patch
obsolete
>From 27555135fef5e5ca7219a2e073c359a0108e639a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 3 Jan 2022 11:31:54 +0100 >Subject: [PATCH] Bug 29778: Prevent orphan additional contents > >When deleting a content, only the main one (lang="default") is removed, >which leads to orphan contents in the DB that are still displayed on the >UI. > >Test plan: >0. Don't apply this patch >1. Create some contents, translate them in different languages >2. Delete some of them >=> Note that they are still displayed on the UI and that the entries >with lang!="default" are still in the DB >3. Apply this patch >4. Repeat 1 >5. Run updatedatabase >6. Delete from of the contents >=> Note that the orphan entries created before you applied the patch >have been removed and that the "delete" behaviour is now working >correnctly. > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > 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 > >diff --git a/installer/data/mysql/atomicupdate/bug_29778.pl b/installer/data/mysql/atomicupdate/bug_29778.pl >new file mode 100755 >index 0000000000..c8f25e7c90 >--- /dev/null >+++ b/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" >+ ); >+ }); >+ }, >+} >diff --git a/tools/additional-contents.pl b/tools/additional-contents.pl >index e63a44a809..d5d02f00c9 100755 >--- a/tools/additional-contents.pl >+++ b/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; > } > ); > }; >-- >2.20.1
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 29778
:
128957
|
129038
|
129040
|
129041
|
129218
|
129219