X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FUID.pm;h=3863256f80039d6925014272673422f0780d0dac;hp=c725f035aaf9f0e3f13dfedca90a48322275fe8a;hb=dc83512c36dc6bea2585abada4f88d714c600e55;hpb=7ef4359e182c1621b233ff3507f2898812ec7727 diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm index c725f035a..3863256f8 100644 --- a/FS/FS/UID.pm +++ b/FS/FS/UID.pm @@ -5,16 +5,16 @@ use strict; use vars qw( @EXPORT_OK $DEBUG $me $cgi $freeside_uid $conf_dir $cache_dir $secrets $datasrc $db_user $db_pass $schema $dbh $driver_name - $AutoCommit %callback @callback $callback_hack + $AutoCommit $ForceObeyAutoCommit %callback @callback $callback_hack ); use subs qw( getsecrets ); use Carp qw( carp croak cluck confess ); -use DBI; +use FS::DBI; use IO::File; use FS::CurrentUser; @EXPORT_OK = qw( checkeuid checkruid cgi setcgi adminsuidsetup forksuidsetup - preuser_setup + preuser_setup load_schema getotaker dbh datasrc getsecrets driver_name myconnect ); @@ -26,7 +26,17 @@ $freeside_uid = scalar(getpwnam('freeside')); $conf_dir = "%%%FREESIDE_CONF%%%"; $cache_dir = "%%%FREESIDE_CACHE%%%"; +# Code wanting to issue a COMMIT statement to the database is expected to +# obey the convention of checking this flag first. Setting $AutoCommit = 0 +# should (usually) suppress COMMIT statements. $AutoCommit = 1; #ours, not DBI + +# Not all methods obey $AutoCommit, by design choice. Setting +# $ForceObeyAutoCommit = 1 will override that design choice for: +# &FS::cust_main::Billing::collect +# &FS::cust_main::Billing::do_cust_event +$ForceObeyAutoCommit = 0; + $callback_hack = 0; =head1 NAME @@ -113,6 +123,14 @@ sub env_setup { } +sub load_schema { + warn "$me loading schema\n" if $DEBUG; + getsecrets() unless $datasrc; + use FS::Schema qw(reload_dbdef dbdef); + reload_dbdef("$conf_dir/dbdef.$datasrc") + unless $FS::Schema::setup_hack; +} + sub db_setup { croak "Not running uid freeside (\$>=$>, \$<=$<)\n" unless checkeuid(); @@ -121,10 +139,7 @@ sub db_setup { warn "$me forksuidsetup connected to database with handle $dbh\n" if $DEBUG; - warn "$me forksuidsetup loading schema\n" if $DEBUG; - use FS::Schema qw(reload_dbdef dbdef); - reload_dbdef("$conf_dir/dbdef.$datasrc") - unless $FS::Schema::setup_hack; + load_schema(); warn "$me forksuidsetup deciding upon config system to use\n" if $DEBUG; @@ -157,14 +172,16 @@ sub callback_setup { } sub myconnect { - my $handle = DBI->connect( getsecrets(), { 'AutoCommit' => 0, - 'ChopBlanks' => 1, - 'ShowErrorStatement' => 1, - 'pg_enable_utf8' => 1, - #'mysql_enable_utf8' => 1, - } - ) - or die "DBI->connect error: $DBI::errstr\n"; + my $handle = FS::DBI->connect( + getsecrets(), + { + 'AutoCommit' => 0, + 'ChopBlanks' => 1, + 'ShowErrorStatement' => 1, + 'pg_enable_utf8' => 1, + # 'mysql_enable_utf8' => 1, + } + ) or die "FS::DBI->connect error: $FS::DBI::errstr\n"; $FS::Conf::conf_cache = undef; @@ -205,7 +222,7 @@ sub install_callback { =item cgi -Returns the CGI (see L) object. +(Deprecated) Returns the CGI (see L) object. =cut @@ -215,9 +232,9 @@ sub cgi { $cgi; } -=item cgi CGI_OBJECT +=item setcgi CGI_OBJECT -Sets the CGI (see L) object. +(Deprecated) Sets the CGI (see L) object. =cut