diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2014-02-20 17:02:33 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-02-27 17:27:25 +0000 |
commit | 5ba57c5a9c8ecc51e73075fa003afa3694e7d269 (patch) | |
tree | 00ed24d5da9c054fac7b47bc585516b61ba079c2 /perllib/Open311 | |
parent | cebc2d4fe88228a9864e737c9cdbdf94629f1554 (diff) |
Fix uncommon Open311 errors on processing updates.
Fixes #677. The query to fetch the related alert sometimes:
* retrieves no result, causing an error on $alert->id
* retrieves multiple results, causing deprecation warnings
(e.g. which may at some point become future errors in DBIC)
This commit turns the resultset('DB::Alert')->find(...) into a
search(...) and loops over the results, to suppress them.
Diffstat (limited to 'perllib/Open311')
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 114a9cd8d..f7b758137 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -139,17 +139,19 @@ sub update_comments { $comment->insert(); if ( $self->suppress_alerts ) { - my $alert = FixMyStreet::App->model('DB::Alert')->find( { + my @alerts = FixMyStreet::App->model('DB::Alert')->search( { alert_type => 'new_updates', parameter => $p->id, confirmed => 1, user_id => $p->user->id, } ); - my $alerts_sent = FixMyStreet::App->model('DB::AlertSent')->find_or_create( { - alert_id => $alert->id, - parameter => $comment->id, - } ); + for my $alert (@alerts) { + my $alerts_sent = FixMyStreet::App->model('DB::AlertSent')->find_or_create( { + alert_id => $alert->id, + parameter => $comment->id, + } ); + } } } } |