summaryrefslogtreecommitdiff
path: root/FS/FS/UID.pm
diff options
context:
space:
mode:
authorjeff <jeff>2007-07-12 13:36:27 +0000
committerjeff <jeff>2007-07-12 13:36:27 +0000
commitcd907554f4c08175c379e204e28e26483acf957a (patch)
treef07a03443fcb8e1673ba24af0ef729e440f3ed4c /FS/FS/UID.pm
parent161172b3162b1495e3d8d0f7425a8b699ffab9fe (diff)
refactor freeside-init-config to module code, compare results of old/new code, have freeside-upgrade complain and revert to old code/config on failure (#1477)
Diffstat (limited to 'FS/FS/UID.pm')
-rw-r--r--FS/FS/UID.pm30
1 files changed, 27 insertions, 3 deletions
diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm
index 986692f..4e3ac81 100644
--- a/FS/FS/UID.pm
+++ b/FS/FS/UID.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw(
@ISA @EXPORT_OK $cgi $dbh $freeside_uid $user
$conf_dir $secrets $datasrc $db_user $db_pass %callback @callback
- $driver_name $AutoCommit $callback_hack
+ $driver_name $AutoCommit $callback_hack $use_confcompat
);
use subs qw(
getsecrets cgisetotaker
@@ -17,13 +17,15 @@ use FS::CurrentUser;
@ISA = qw(Exporter);
@EXPORT_OK = qw(checkeuid checkruid cgisuidsetup adminsuidsetup forksuidsetup
- getotaker dbh datasrc getsecrets driver_name myconnect );
+ getotaker dbh datasrc getsecrets driver_name myconnect
+ use_confcompat);
$freeside_uid = scalar(getpwnam('freeside'));
-$conf_dir = "%%%FREESIDE_CONF%%%/";
+$conf_dir = "%%%FREESIDE_CONF%%%";
$AutoCommit = 1; #ours, not DBI
+$use_confcompat = 1;
$callback_hack = 0;
=head1 NAME
@@ -105,6 +107,18 @@ sub forksuidsetup {
FS::CurrentUser->load_user($user);
+ if ($dbh && ! $callback_hack) {
+ my $sth = $dbh->prepare("SELECT COUNT(*) FROM conf") or die $dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ my $confcount = $sth->fetchrow_arrayref->[0];
+
+ if ($confcount) {
+ $use_confcompat = 0;
+ }else{
+ warn "NO CONFIGURATION RECORDS FOUND" unless $confcount;
+ }
+ }
+
unless($callback_hack) {
foreach ( keys %callback ) {
&{$callback{$_}};
@@ -299,6 +313,16 @@ sub getsecrets {
($datasrc, $db_user, $db_pass);
}
+=item use_confcompat
+
+Returns true whenever we should use 1.7 configuration compatibility.
+
+=cut
+
+sub use_confcompat {
+ $use_confcompat;
+}
+
=back
=head1 CALLBACKS