Bug 19675 - Cannot save notices when setting the TranslateNotices preference
Summary: Cannot save notices when setting the TranslateNotices preference
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Notices (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Andreas Jonsson
QA Contact: Testopia
URL:
Keywords:
: 19516 (view as bug list)
Depends on: 17762
Blocks:
  Show dependency treegraph
 
Reported: 2017-11-21 16:20 UTC by Andreas Jonsson
Modified: 2019-10-14 19:57 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 19675: Fix update notice templates when they are translatable (1.30 KB, patch)
2017-11-26 17:12 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 19675: Fix update notice templates when they are translatable (1.37 KB, patch)
2017-11-26 17:14 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Jonsson 2017-11-21 16:20:53 UTC
The lang parameter is missing in the where clause of the update statement.  The below patch fixes the problem.

diff --git a/tools/letter.pl b/tools/letter.pl
index 5920a8437f..f89930472c 100755
--- a/tools/letter.pl
+++ b/tools/letter.pl
@@ -303,11 +303,11 @@ sub add_validate {
                 q{
                     UPDATE letter
                     SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?, lang = ?
-                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?
+                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ? AND lang = ?
                 },
                 undef,
                 $branchcode || '', $module, $name, $is_html || 0, $title, $content, $lang,
-                $branchcode, $oldmodule, $code, $mtt
+                $branchcode, $oldmodule, $code, $mtt, $lang
             );
         } else {
             $dbh->do(



To reproduce:

1. Enable TranslateNotices global preference.
2. Edit any notice message and save a translation.
3. Try updating any translation.  The save will fail and the log-file will contain errors such as this:

DBIx::Class::Storage::DBI::select_single(): Query returned more than one row.  SQL that returns multiple rows is DEPRECATED for ->find and ->single at /usr/share/koha/lib/Koha/Objects.pm line 92
DBIx::Class::Storage::DBI::select_single(): Query returned more than one row.  SQL that returns multiple rows is DEPRECATED for ->find and ->single at /usr/share/koha/lib/Koha/Objects.pm line 92
DBD::mysql::db do failed: Duplicate entry 'circulation-ODUE--email-sv-SE' for key 'PRIMARY' [for Statement "
                    UPDATE letter
                    SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?, lang = ?
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?
                "] at /usr/share/koha/intranet/cgi-bin/tools/letter.pl line 302.
DBD::mysql::db do failed: Duplicate entry 'circulation-ODUE--email-en' for key 'PRIMARY' [for Statement "
                    UPDATE letter
                    SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ?, lang = ?
                    WHERE branchcode = ? AND module = ? AND code = ? AND message_transport_type = ?
                "] at /usr/share/koha/intranet/cgi-bin/tools/letter.pl line 302.
Comment 1 Magnus Enger 2017-11-24 06:47:29 UTC
Could you please attach the diff as a Git patch? There are some good tips about the easiest way to do that here:
https://wiki.koha-community.org/wiki/Git_bz_configuration
Comment 2 Jonathan Druart 2017-11-26 17:12:15 UTC
Created attachment 69347 [details] [review]
Bug 19675: Fix update notice templates when they are translatable

Avoid the following error:
DBD::mysql::db do failed: Duplicate entry
'acquisition-xxx--email-default' for key 'PRIMARY' [for Statement "
Comment 3 Jonathan Druart 2017-11-26 17:14:12 UTC
Created attachment 69348 [details] [review]
Bug 19675: Fix update notice templates when they are translatable

Avoid the following error:
DBD::mysql::db do failed: Duplicate entry
'acquisition-xxx--email-default' for key 'PRIMARY' [for Statement "

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Jonathan Druart 2017-11-26 17:14:44 UTC
Skipping QA.
Comment 5 Jonathan Druart 2017-11-26 18:55:08 UTC
Path pushed to master for 17.11, thanks Andreas and congrats for your first patch in!
Comment 6 Andreas Jonsson 2017-11-26 20:26:51 UTC
Thanks you for pushing this so swiftly!
Comment 7 Katrin Fischer 2017-12-05 10:29:03 UTC
*** Bug 19516 has been marked as a duplicate of this bug. ***