aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Script
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-11-02 17:14:58 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-11-06 11:52:07 +0000
commita4524f33c78674e4ab5f920f38353a3feff6b6e1 (patch)
tree708cdd5220a9c12d013f70c623139e56be9c88b9 /perllib/FixMyStreet/Script
parent0cbbf0f2e23069deddc9dbfc836bfdf9e4442c54 (diff)
Deal with possible multiple send_method_useds.
Diffstat (limited to 'perllib/FixMyStreet/Script')
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index dd8f4e370..5cadd4fa2 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -211,12 +211,13 @@ sub send(;$) {
# Multiply results together, so one success counts as a success.
my $result = -1;
+ my @methods;
for my $sender ( keys %reporters ) {
debug_print("sending using " . $sender, $row->id) if $debug_mode;
$sender = $reporters{$sender};
my $res = $sender->send( $row, \%h );
$result *= $res;
- $row->add_send_method($sender) if !$res;
+ push @methods, $sender if !$res;
if ( $sender->unconfirmed_counts) {
foreach my $e (keys %{ $sender->unconfirmed_counts } ) {
foreach my $c (keys %{ $sender->unconfirmed_counts->{$e} }) {
@@ -229,6 +230,12 @@ sub send(;$) {
if FixMyStreet->test_mode && $sender->can('open311_test_req_used');
}
+ # Add the send methods now because e.g. Open311
+ # send() calls $row->discard_changes
+ foreach (@methods) {
+ $row->add_send_method($_);
+ }
+
unless ($result) {
$row->update( {
whensent => \'current_timestamp',