[freeside-commits] branch FREESIDE_3_BRANCH updated. 152c54a5c8277fb09429d6ded83535edd0a914f2
Mark Wells
mark at 420.am
Tue Dec 22 17:23:40 PST 2015
The branch, FREESIDE_3_BRANCH has been updated
via 152c54a5c8277fb09429d6ded83535edd0a914f2 (commit)
from 659bfc275fe537566bfde62b3a2a7477e10e0bc0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 152c54a5c8277fb09429d6ded83535edd0a914f2
Author: Mark Wells <mark at freeside.biz>
Date: Tue Dec 22 17:03:07 2015 -0800
improve handling of internal errors from US Census geocoding, #39549
diff --git a/FS/FS/Misc/Geo.pm b/FS/FS/Misc/Geo.pm
index 168e4e9..c02d5dd 100644
--- a/FS/FS/Misc/Geo.pm
+++ b/FS/FS/Misc/Geo.pm
@@ -11,6 +11,7 @@ use JSON;
use URI::Escape 3.31;
use Data::Dumper;
use FS::Conf;
+use FS::Log;
use Locale::Country;
FS::UID->install_callback( sub {
@@ -300,6 +301,8 @@ sub standardize_usps {
sub standardize_uscensus {
my $self = shift;
my $location = shift;
+ my $log = FS::Log->new('FS::Misc::Geo::standardize_uscensus');
+ $log->debug(join("\n", @{$location}{'address1', 'city', 'state', 'zip'}));
eval "use Geo::USCensus::Geocoding";
die $@ if $@;
@@ -322,6 +325,7 @@ sub standardize_uscensus {
my $result = Geo::USCensus::Geocoding->query($request);
if ( $result->is_match ) {
# unfortunately we get the address back as a single line
+ $log->debug($result->address);
if ($result->address =~ /^(.*), (.*), ([A-Z]{2}), (\d{5}.*)$/) {
return +{
address1 => $1,
@@ -341,8 +345,8 @@ sub standardize_uscensus {
} elsif ( $result->match_level ) {
die "Geocoding did not find a matching address.\n";
} else {
- warn Dumper($result) if $DEBUG;
- die $result->error_message;
+ $log->error($result->error_message);
+ return; # for internal errors, don't return anything
}
}
diff --git a/FS/FS/geocode_Mixin.pm b/FS/FS/geocode_Mixin.pm
index 0625b5a..bc8c118 100644
--- a/FS/FS/geocode_Mixin.pm
+++ b/FS/FS/geocode_Mixin.pm
@@ -140,7 +140,7 @@ Returns the full country name.
sub country_full {
my $self = shift;
- $self->code2country($self->country);
+ $self->code2country($self->get('country'));
}
sub code2country {
diff --git a/FS/FS/log.pm b/FS/FS/log.pm
index a4ad214..753a31f 100644
--- a/FS/FS/log.pm
+++ b/FS/FS/log.pm
@@ -114,7 +114,7 @@ sub check {
|| $self->ut_textn('tablename')
|| $self->ut_numbern('tablenum')
|| $self->ut_number('level')
- || $self->ut_text('message')
+ || $self->ut_anything('message')
;
return $error if $error;
diff --git a/FS/FS/log_context.pm b/FS/FS/log_context.pm
index b2126b8..718b4d5 100644
--- a/FS/FS/log_context.pm
+++ b/FS/FS/log_context.pm
@@ -9,6 +9,7 @@ my @contexts = ( qw(
bill_and_collect
FS::cust_main::Billing::bill_and_collect
FS::cust_main::Billing::bill
+ FS::Misc::Geo::standardize_uscensus
Cron::bill
Cron::upload
spool_upload
diff --git a/httemplate/elements/standardize_locations.js b/httemplate/elements/standardize_locations.js
index c285737..fed5733 100644
--- a/httemplate/elements/standardize_locations.js
+++ b/httemplate/elements/standardize_locations.js
@@ -114,7 +114,12 @@ function confirm_standardize(arg) {
// then all entered address fields are correct
// but we still need to set the lat/long fields and addr_clean
- status_message('Verified');
+
+ if ( returned['addr_clean'] ) {
+ status_message('Verified');
+ } else {
+ status_message('Unverified');
+ }
replace_address();
} else {
diff --git a/httemplate/search/log.html b/httemplate/search/log.html
index d1bfb6c..7714f46 100644
--- a/httemplate/search/log.html
+++ b/httemplate/search/log.html
@@ -137,7 +137,7 @@ my $tt_sub = sub {
return '' if @context == 1 and length($log->message) <= 60;
my $html = '<DIV CLASS="tooltip">'.(shift @context).'</DIV>';
my $pre = '↳';
- foreach (@context, $log->message) {
+ foreach (map encode_entities($_), @context, $log->message) {
$html .= "<DIV>$pre$_</DIV>";
$pre = ' '.$pre;
}
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Misc/Geo.pm | 8 ++++++--
FS/FS/geocode_Mixin.pm | 2 +-
FS/FS/log.pm | 2 +-
FS/FS/log_context.pm | 1 +
httemplate/elements/standardize_locations.js | 7 ++++++-
httemplate/search/log.html | 2 +-
6 files changed, 16 insertions(+), 6 deletions(-)
More information about the freeside-commits
mailing list