Bugzilla – Attachment 129050 Details for
Bug 29805
Database update fails in MySQL 5.7 because it's missing REGEXP_REPLACE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29805: Fix 21.05.00.016 for MySQL 5.7
Bug-29805-Fix-210500016-for-MySQL-57.patch (text/plain), 2.48 KB, created by
Jonathan Druart
on 2022-01-06 10:58:53 UTC
(
hide
)
Description:
Bug 29805: Fix 21.05.00.016 for MySQL 5.7
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-01-06 10:58:53 UTC
Size:
2.48 KB
patch
obsolete
>From af1c7a3ed2292b85bd3fb81ca89457f16ded92b1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 Jan 2022 11:38:04 +0100 >Subject: [PATCH] Bug 29805: Fix 21.05.00.016 for MySQL 5.7 > >MySQL 5.7 is in Ubuntu 18.04 and does not support REGEXP_REPLACE. We can >easily rewrite it in Perl instead of dropping support on this Ubuntu LTS >version. > >Test plan: >checkout a commit prior to 21.05.00.016 >Create a notice template with > <<opac_news.content>> > [%opac_news.content %] > << opac_news.content>> > [% opac_news.content %] > >Note that ISSUESLIP has already occurrence of 'opac_news.' > >git checkout a branch with master + this patch >Run `updatedatabase` and notice that the 'opac_news.' occurrences have >been replaced with 'additional_contents.' >--- > installer/data/mysql/db_revs/210600016.pl | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > >diff --git a/installer/data/mysql/db_revs/210600016.pl b/installer/data/mysql/db_revs/210600016.pl >index 8d66de86cbf..ded77e69570 100755 >--- a/installer/data/mysql/db_revs/210600016.pl >+++ b/installer/data/mysql/db_revs/210600016.pl >@@ -38,14 +38,18 @@ return { > |); > } > >- $dbh->do(q| >- UPDATE letter >- SET content = REGEXP_REPLACE(content, '<<\\\\s*opac_news\.', '<<additional_contents.') >- |); >- $dbh->do(q| >- UPDATE letter >- SET content = REGEXP_REPLACE(content, '\\\\[%\\\\s*opac_news\.', '[% additional_contents.') >+ my $contents = $dbh->selectall_arrayref(q|SELECT * FROM additional_contents|, { Slice => {} }); >+ my $sth_update = $dbh->prepare(q| >+ UPDATE additional_contents >+ SET content=? >+ WHERE idnew=? > |); >+ for my $c ( @$contents ) { >+ my $content = $c->{content}; >+ $content =~ s|<<\s*opac_news\.|<<additional_contents.|g; >+ $content =~ s|\[%\s*opac_news\.|[% additional_contents.|g; >+ $sth_update->execute($content, $c->{idnew}); >+ } > > $dbh->do(q| > UPDATE systempreferences >@@ -82,7 +86,7 @@ return { > |); > } > >- my $contents = $dbh->selectall_arrayref(q|SELECT * FROM additional_contents|, { Slice => {} }); >+ $contents = $dbh->selectall_arrayref(q|SELECT * FROM additional_contents|, { Slice => {} }); > for my $c ( @$contents ) { > my ( $category, $location, $new_lang ); > if ( $c->{lang} eq '' ) { >-- >2.25.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 29805
:
129050
|
129074