aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-05-22 10:03:54 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-05-22 10:04:30 +0100
commitb9ecf64878bd7ee4b0771a17a244dd29b81d504c (patch)
tree1ae6f893b6a95ec7a5393f90fdf20792a3189d2c
parent57e039927286162db43e0557a00c4703d2c198a2 (diff)
Initialise variables so that we don't try and encode undef.
-rwxr-xr-xbin/send-reports5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 9b31b61ab..5f3a508b7 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -489,7 +489,7 @@ sub post_barnet_message {
my $interface = BarnetInterfaces::service::ZLBB_SERVICE_ORDER->new();
- my ($nearest_postcode, $nearest_street);
+ my ($nearest_postcode, $nearest_street) = ('', '');
for ($h{closest_address}) {
$nearest_postcode = sprintf("%-10s", $1) if /Nearest postcode [^:]+: ((\w{1,4}\s?\w+|\w+))/;
# use partial postcode or comma as delimiter, strip leading number (possible letter 221B) off too
@@ -497,7 +497,8 @@ sub post_barnet_message {
# "99 Foo Street N11 1XX" becomes Foo Street
$nearest_street = $1 if /Nearest road [^:]+: (?:\d+\w? )?(.*?)(\b[A-Z]+\d|,|$)/m;
}
- my $postcode = $h{postcode} || $nearest_postcode; # use given postcode if available
+ my $postcode = mySociety::PostcodeUtil::is_valid_postcode($h{query})
+ ? $h{query} : $nearest_postcode; # use given postcode if available
# note: endpoint can be of form 'https://username:password@url'
my $council_config = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => COUNCIL_ID_BARNET} )->first;