word edit: recover form after save error
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 25 May 2020 03:22:47 +0000 (05:22 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 6 Jun 2020 01:49:20 +0000 (03:49 +0200)
writer.plp

index 11754e8a72d4b1834aa904126ad158cda5fee5f4..288891a5030688489ae47bcff3c1a7347f0d0411 100644 (file)
@@ -127,7 +127,7 @@ if ($find) {
 if (exists $get{copy}) {
        $row = {%{$row}{ qw(lang cat) }};
 }
-elsif ($ENV{REQUEST_METHOD} eq 'POST') {
+elsif ($ENV{REQUEST_METHOD} eq 'POST') {{
        my $replace = $row;
        $row = {%post{ pairkeys @wordcols }};
        $_ = length ? $_ : undef for values %{$row};
@@ -137,7 +137,10 @@ elsif ($ENV{REQUEST_METHOD} eq 'POST') {
                my $query = $find ? $db->update(word => $row, $find, \%res) :
                        $db->insert(word => $row, \%res);
                $row = $query->hash;
-       } or Alert("Entry could not be saved", $@);
+       } or do {
+               Alert("Entry could not be saved", $@);
+               next;
+       };
 
        my $imgpath = "data/word/org/$row->{id}.jpg";
        if (($row->{source} // '') ne ($replace->{source} // '')) {
@@ -182,7 +185,7 @@ elsif ($ENV{REQUEST_METHOD} eq 'POST') {
                        unlink $thumbpath;
                }
        }
-}
+}}
 else {
        $row->{$_} = $get{$_} for keys %get;
 }