[freeside-commits] branch FREESIDE_4_BRANCH updated. 1f485a64aa2868036eb17e122191ab8e8868a947
Ivan
ivan at 420.am
Fri Mar 10 11:42:26 PST 2017
The branch, FREESIDE_4_BRANCH has been updated
via 1f485a64aa2868036eb17e122191ab8e8868a947 (commit)
from f9859a1893c22322fcb3f3aa7c4a022a5d919897 (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 1f485a64aa2868036eb17e122191ab8e8868a947
Author: Ivan Kohler <ivan at freeside.biz>
Date: Fri Mar 10 11:42:26 2017 -0800
fix dangling RADIUS attributes on upgrade (and prevent new ones from showing up), RT#75116
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index b6dcbd8..3b76bb5 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -576,6 +576,7 @@ sub upgrade_schema_data {
'cust_msg' => [],
'cust_bill_pay_batch' => [],
'cust_event_fee' => [],
+ 'radius_attr' => [],
#update records referencing removed things with their FKs
'cust_pkg' => [],
;
diff --git a/FS/FS/radius_attr.pm b/FS/FS/radius_attr.pm
index 16d3f62..1b7df2e 100644
--- a/FS/FS/radius_attr.pm
+++ b/FS/FS/radius_attr.pm
@@ -3,7 +3,7 @@ use base qw( FS::Record );
use strict;
use vars qw( $noexport_hack );
-use FS::Record qw( qsearch ); #qsearchs );
+use FS::Record qw( qsearch dbh );
$noexport_hack = 0;
@@ -202,6 +202,21 @@ sub ops {
=back
+=cut
+
+sub _upgrade_schema {
+ my ($class, %opts) = @_;
+
+ my $sql = '
+ DELETE FROM radius_attr WHERE NOT EXISTS
+ ( SELECT 1 FROM radius_group WHERE radius_group.groupnum = radius_attr.groupnum )
+ ';
+
+ my $sth = dbh->prepare($sql) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ '';
+}
+
=head1 BUGS
=head1 SEE ALSO
diff --git a/FS/FS/radius_group.pm b/FS/FS/radius_group.pm
index f1a4efe..21ce25f 100644
--- a/FS/FS/radius_group.pm
+++ b/FS/FS/radius_group.pm
@@ -1,8 +1,8 @@
package FS::radius_group;
+use base qw( FS::o2m_Common FS::Record );
use strict;
-use base qw( FS::o2m_Common FS::Record );
-use FS::Record qw( qsearch qsearchs dbh );
+use FS::Record qw( qsearch dbh );
use FS::radius_attr;
=head1 NAME
@@ -125,6 +125,15 @@ sub delete {
return $error;
}
}
+
+ foreach my $radius_attr ( $self->radius_attr ) {
+ $error = $radius_attr->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
dbh->commit;
'';
}
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Upgrade.pm | 1 +
FS/FS/radius_attr.pm | 17 ++++++++++++++++-
FS/FS/radius_group.pm | 13 +++++++++++--
3 files changed, 28 insertions(+), 3 deletions(-)
More information about the freeside-commits
mailing list