[freeside-commits] branch master updated. e3012c0751dad6710ea35b6d074b551bffdad09b

Mark Wells mark at 420.am
Fri Sep 27 16:02:23 PDT 2013


The branch, master has been updated
       via  e3012c0751dad6710ea35b6d074b551bffdad09b (commit)
      from  0792a884aea4a30b1c227875a88270928602ff00 (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 e3012c0751dad6710ea35b6d074b551bffdad09b
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Sep 27 16:02:03 2013 -0700

    clean up invalid ticket links on upgrade, #25067

diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm
index c1c69fa..fa54e0b 100644
--- a/FS/FS/TicketSystem.pm
+++ b/FS/FS/TicketSystem.pm
@@ -342,6 +342,21 @@ sub _upgrade_data {
     or die $dbh->errstr;
   $cve_2013_3373_sth->execute or die $cve_2013_3373_sth->errstr;
 
+  # Remove dangling customer links, if any
+  my %target_pkey = ('cust_main' => 'custnum', 'cust_svc' => 'svcnum');
+  for my $table (keys %target_pkey) {
+    my $pkey = $target_pkey{$table};
+    my $rows = $dbh->do(
+      "DELETE FROM links WHERE id IN(".
+        "SELECT links.id FROM links LEFT JOIN $table ON (links.target = ".
+        "'freeside://freeside/$table/' || $table.$pkey) ".
+        "WHERE links.target like 'freeside://freeside/$table/%' ".
+        "AND $table.$pkey IS NULL".
+      ")"
+    ) or die $dbh->errstr;
+    warn "Removed $rows dangling ticket-$table links\n" if $rows > 0;
+  }
+
   return;
 }
 
diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm
index 5dc92d4..d1479b5 100644
--- a/rt/lib/RT/URI/freeside/Internal.pm
+++ b/rt/lib/RT/URI/freeside/Internal.pm
@@ -211,7 +211,6 @@ sub CustomerResolver {
 sub CustomerInfo {
   my $self = shift;
   $self = $self->CustomerResolver;
-  my $rec;
   my $rec = $self->_FreesideGetRecord() if $self;
   if (!$rec) {
     # AsStringLong will report an error;

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

Summary of changes:
 FS/FS/TicketSystem.pm              |   15 +++++++++++++++
 rt/lib/RT/URI/freeside/Internal.pm |    1 -
 2 files changed, 15 insertions(+), 1 deletions(-)




More information about the freeside-commits mailing list