From af1c7a3ed2292b85bd3fb81ca89457f16ded92b1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart 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 %] 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\.', '<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\.|<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