[freeside-commits] branch FREESIDE_3_BRANCH updated. c64ff892b9067f7aa719e78b20379d3274907946

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


The branch, FREESIDE_3_BRANCH has been updated
       via  c64ff892b9067f7aa719e78b20379d3274907946 (commit)
      from  e171647bc34d730d982c0e08d9731bbeb414be31 (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 c64ff892b9067f7aa719e78b20379d3274907946
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Sep 27 16:02:16 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