Bugzilla – Attachment 157544 Details for
Bug 31383
Additional contents: We need a parent and child table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31383: Restore updated_on for individual content
Bug-31383-Restore-updatedon-for-individual-content.patch (text/plain), 8.19 KB, created by
Jonathan Druart
on 2023-10-20 15:06:57 UTC
(
hide
)
Description:
Bug 31383: Restore updated_on for individual content
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-10-20 15:06:57 UTC
Size:
8.19 KB
patch
obsolete
>From 65a0297b8d976ea027a5c6f7066fd808779581a3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 8 Mar 2023 10:56:07 +0100 >Subject: [PATCH] Bug 31383: Restore updated_on for individual content > >Sponsored-by: Rijksmuseum, Netherlands >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/AdditionalContentsLocalization.pm | 13 ------------ > .../Result/AdditionalContentsLocalization.pm | 20 +++++++++++++++++-- > .../data/mysql/atomicupdate/bug_31383.pl | 9 +++++---- > installer/data/mysql/kohastructure.sql | 1 + > tools/additional-contents.pl | 19 ++++++++++-------- > 5 files changed, 35 insertions(+), 27 deletions(-) > >diff --git a/Koha/AdditionalContentsLocalization.pm b/Koha/AdditionalContentsLocalization.pm >index 82bd961c2ac..f70def51c7b 100644 >--- a/Koha/AdditionalContentsLocalization.pm >+++ b/Koha/AdditionalContentsLocalization.pm >@@ -150,19 +150,6 @@ sub published_on { > return $self->additional_content->published_on(@params); > } > >-=head3 updated_on >- >- $c->updated_on; >- >-Return the date of the last update of the content >- >-=cut >- >-sub updated_on { >- my ( $self, @params ) = @_; >- return $self->additional_content->updated_on(@params); >-} >- > =head3 expirationdate > > $c->expirationdate; >diff --git a/Koha/Schema/Result/AdditionalContentsLocalization.pm b/Koha/Schema/Result/AdditionalContentsLocalization.pm >index 6553f8bb045..ed4fb504ab2 100644 >--- a/Koha/Schema/Result/AdditionalContentsLocalization.pm >+++ b/Koha/Schema/Result/AdditionalContentsLocalization.pm >@@ -66,6 +66,15 @@ the body of your additional content > > lang > >+=head2 updated_on >+ >+ data_type: 'timestamp' >+ datetime_undef_if_invalid: 1 >+ default_value: current_timestamp >+ is_nullable: 0 >+ >+last modification >+ > =cut > > __PACKAGE__->add_columns( >@@ -89,6 +98,13 @@ __PACKAGE__->add_columns( > { data_type => "mediumtext", is_nullable => 0 }, > "lang", > { data_type => "varchar", default_value => "", is_nullable => 0, size => 50 }, >+ "updated_on", >+ { >+ data_type => "timestamp", >+ datetime_undef_if_invalid => 1, >+ default_value => \"current_timestamp", >+ is_nullable => 0, >+ }, > ); > > =head1 PRIMARY KEY >@@ -140,8 +156,8 @@ __PACKAGE__->belongs_to( > ); > > >-# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-08 08:09:35 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KRaaWslsavWVmDbZF/NwcQ >+# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-08 09:59:00 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7N/mHMqyPJJsYaA8V968wQ > > sub koha_object_class { > 'Koha::AdditionalContentsLocalization'; >diff --git a/installer/data/mysql/atomicupdate/bug_31383.pl b/installer/data/mysql/atomicupdate/bug_31383.pl >index 2bda07cb888..3a3d7584f5d 100755 >--- a/installer/data/mysql/atomicupdate/bug_31383.pl >+++ b/installer/data/mysql/atomicupdate/bug_31383.pl >@@ -20,6 +20,7 @@ return { > `title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content', > `content` mediumtext NOT NULL COMMENT 'the body of your additional content', > `lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang', >+ `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification', > PRIMARY KEY (`id`), > UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`), > CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE >@@ -29,19 +30,19 @@ return { > > my $contents = $dbh->selectall_arrayref(q{SELECT MIN(id) AS id, category, code, branchcode FROM additional_contents GROUP BY category, code, branchcode}, { Slice => {} }); > my $sth_insert = $dbh->prepare(q{ >- INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang) >- VALUES(?, ?, ?, ?) >+ INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang, updated_on) >+ VALUES(?, ?, ?, ?, ?) > }); > for my $content ( @$contents ) { > my $q = q{ >- SELECT title, content, lang, branchcode >+ SELECT title, content, lang, branchcode, updated_on > FROM additional_contents > WHERE category=? AND code=? AND > }; > $q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL"; > my $translated_contents = $dbh->selectall_arrayref($q, { Slice => {} }, $content->{category}, $content->{code}, defined $content->{branchcode} ? $content->{branchcode} : ()); > for my $translated_content ( @$translated_contents ) { >- $sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang}); >+ $sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang}, $translated_content->{updated_on}); > } > } > $dbh->do(q{ >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 3e37e15b35c..30766f38f77 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -217,6 +217,7 @@ CREATE TABLE `additional_contents_localizations` ( > `title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content', > `content` mediumtext NOT NULL COMMENT 'the body of your additional content', > `lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang', >+ `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification', > PRIMARY KEY (`id`), > UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`), > CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE >diff --git a/tools/additional-contents.pl b/tools/additional-contents.pl >index 75c32ca9c36..988089025ff 100755 >--- a/tools/additional-contents.pl >+++ b/tools/additional-contents.pl >@@ -135,23 +135,26 @@ elsif ( $op eq 'add_validate' ) { > next unless $title || $content; > > push @seen_ids, $id; >- push @translated_contents, >- { >+ my $translated_content = { > title => $title, > content => $content, > lang => $lang, >- }; >+ }; > >- if ( C4::Context->preference("NewsLog") ) { >- my $existing_content = $existing_contents->find($id); >- if ( $existing_content ) { >- if ( $existing_content->title ne $title || $existing_content->content ne $content ) { >+ my $existing_content = $existing_contents->find($id); >+ if ( $existing_content ) { >+ if ( $existing_content->title ne $title || $existing_content->content ne $content ) { >+ if ( C4::Context->preference("NewsLog") ) { > logaction('NEWS', 'MODIFY' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content)); > } > } else { >- logaction('NEWS', 'ADD' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content)) >+ $translated_content->{updated_on} = $existing_content->updated_on; > } >+ } elsif( C4::Context->preference("NewsLog") ) { >+ logaction('NEWS', 'ADD' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content)) > } >+ >+ push @translated_contents, $translated_content; > } > > if ( C4::Context->preference("NewsLog") ) { >-- >2.34.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 31383
:
147891
|
147892
|
147893
|
147894
|
147895
|
147896
|
149813
|
149814
|
149815
|
149816
|
149817
|
149818
|
152423
|
152424
|
152425
|
152426
|
152427
|
152428
|
152545
|
152546
|
152547
|
152566
|
152660
|
152661
|
152662
|
152663
|
152664
|
152665
|
152666
|
152667
|
152668
|
152669
|
153013
|
153666
|
153667
|
153668
|
153669
|
153670
|
153671
|
153672
|
153673
|
153674
|
153675
|
153676
|
156048
|
156049
|
156050
|
156051
|
156052
|
156053
|
156054
|
156055
|
156056
|
156057
|
156058
|
156265
|
156266
|
156267
|
156268
|
156269
|
156270
|
156271
|
156272
|
156273
|
156274
|
156275
|
156276
|
157539
|
157540
|
157541
|
157542
|
157543
| 157544 |
157545
|
157546
|
157547
|
157548
|
157549
|
157550
|
157580
|
157585
|
157640
|
157741
|
157742