[freeside-commits] branch master updated. 5b884dd940f7dce415ba77dcbc2ab6840f0b5673

Jonathan Prykop jonathan at 420.am
Mon Feb 2 16:53:52 PST 2015


The branch, master has been updated
       via  5b884dd940f7dce415ba77dcbc2ab6840f0b5673 (commit)
       via  e9f799b79fca47ee24d2107a0e5c5114dc4e06d8 (commit)
      from  899cf5029429c1183024cd4bf838573a951d0ede (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 5b884dd940f7dce415ba77dcbc2ab6840f0b5673
Merge: e9f799b 899cf50
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Feb 2 18:51:19 2015 -0600

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit e9f799b79fca47ee24d2107a0e5c5114dc4e06d8
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Feb 2 18:50:47 2015 -0600

    RT#30248: Unable to remove phone number from contact

diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 3205df1..437fd16 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -268,7 +268,7 @@ sub replace {
     return $error;
   }
 
-  foreach my $pf ( grep { /^phonetypenum(\d+)$/ && $self->get($_) }
+  foreach my $pf ( grep { /^phonetypenum(\d+)$/ }
                         keys %{ $self->hashref } ) {
     $pf =~ /^phonetypenum(\d+)$/ or die "wtf (daily, the)";
     my $phonetypenum = $1;
@@ -276,8 +276,21 @@ sub replace {
     my %cp = ( 'contactnum'   => $self->contactnum,
                'phonetypenum' => $phonetypenum,
              );
-    my $contact_phone = qsearchs('contact_phone', \%cp)
-                        || new FS::contact_phone   \%cp;
+    my $contact_phone = qsearchs('contact_phone', \%cp);
+
+    # if new value is empty, delete old entry
+    if (!$self->get($pf)) {
+      if ($contact_phone) {
+        $error = $contact_phone->delete;
+        if ( $error ) {
+          $dbh->rollback if $oldAutoCommit;
+          return $error;
+        }
+      }
+      next;
+    }
+
+    $contact_phone ||= new FS::contact_phone \%cp;
 
     my %cpd = _parse_phonestring( $self->get($pf) );
     $contact_phone->set( $_ => $cpd{$_} ) foreach keys %cpd;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/contact.pm |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list