Bug 8378 - followup - update notices to use <<items.fine>>
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 20 Mar 2013 13:46:07 +0000 (14:46 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Fri, 22 Mar 2013 01:54:04 +0000 (21:54 -0400)
Didn't break on well-formed notices, and fixed those with problems

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
installer/data/mysql/updatedatabase.pl

index e0bcad0..1f5283d 100755 (executable)
@@ -6683,7 +6683,22 @@ if ( CheckVersion($DBversion) ) {
     SetVersion ($DBversion);
 }
 
-
+$DBversion = '3.11.00.XXX';
+if ( CheckVersion($DBversion) ) {
+    my $sth = $dbh->prepare("
+        SELECT module, code, branchcode, content
+        FROM letter
+        WHERE content LIKE '%<fine>%'
+    ");
+    $sth->execute;
+    my $sth_update = $dbh->prepare("UPDATE letter SET content = ? WHERE module = ? AND code = ? AND branchcode = ?");
+    while(my $row = $sth->fetchrow_hashref){
+        $row->{content} =~ s/<fine>\w+<\/fine>/<<items.fine>>/;
+        $sth_update->execute($row->{content}, $row->{module}, $row->{code}, $row->{branchcode});
+    }
+    print "Upgrade to $DBversion done (use new <<items.fine>> syntax in notices)\n";
+    SetVersion ($DBversion);
+}
 
 =head1 FUNCTIONS