aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-03-28 07:56:58 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-03-28 08:00:26 +0000
commit884080d3944b6232aedbb36d830ab6e9dee7d1a5 (patch)
tree74dcc8659e25bf356967b560773da3f6734e784a
parentda2a6dd98d8d5b61b8b5befa717d65689d674ea9 (diff)
Fix archive report script to not skip first row.
->first, as used in cd8a5702, uses the iterator, so ->next will then only return the second onward. Instead, do the needed thing in the first iteration of the loop. Also check the option is set as some scripts do not set it.
-rw-r--r--perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm15
1 files changed, 8 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm
index ce32b0d93..0c938682d 100644
--- a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm
+++ b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm
@@ -139,17 +139,18 @@ sub close_problems {
my $problems = shift;
- return unless $problems->count;
-
my $extra = { auto_closed_by_script => 1 };
$extra->{is_superuser} = 1 if !$opts->{user_name};
- # need to do this again in case no reports were closed with an
- # email in which case we won't have set the lang and domain
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($opts->{cobrand})->new();
- $cobrand->set_lang_and_domain($problems->first->lang, 1);
-
+ my $cobrand;
while (my $problem = $problems->next) {
+ # need to do this in case no reports were closed with an
+ # email in which case we won't have set the lang and domain
+ if ($opts->{cobrand} && !$cobrand) {
+ $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($opts->{cobrand})->new();
+ $cobrand->set_lang_and_domain($problem->lang, 1);
+ }
+
my $timestamp = \'current_timestamp';
my $comment = $problem->add_to_comments( {
text => $opts->{closure_text} || '',