[freeside-commits] freeside/FS/FS/Cron bill.pm, 1.32, 1.33 notify.pm, 1.11, 1.12

Ivan,,, ivan at wavetail.420.am
Mon Oct 18 17:32:12 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS/Cron
In directory wavetail.420.am:/tmp/cvs-serv8782/FS/FS/Cron

Modified Files:
	bill.pm notify.pm 
Log Message:
fix daily billing under mysql, RT#10246

Index: bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Cron/bill.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -d -r1.32 -r1.33
--- bill.pm	19 Sep 2010 00:13:05 -0000	1.32
+++ bill.pm	19 Oct 2010 00:32:10 -0000	1.33
@@ -5,7 +5,7 @@
 use Exporter;
 use Date::Parse;
 use DBI 1.33; #The "clone" method was added in DBI 1.33. 
-use FS::UID qw(dbh);
+use FS::UID qw( dbh driver_name );
 use FS::Record qw( qsearch qsearchs );
 use FS::queue;
 use FS::cust_main;
@@ -56,14 +56,20 @@
 
   my $cursor_dbh = dbh->clone;
 
-  $cursor_dbh->do(
-    "DECLARE cron_bill_cursor CURSOR FOR ".
-    "  SELECT custnum FROM cust_main WHERE ". bill_where( %opt )
-  ) or die $cursor_dbh->errstr;
+  my $select = 'SELECT custnum FROM cust_main WHERE '. bill_where( %opt );
+
+  unless ( driver_name =~ /^mysql/ ) {
+    $cursor_dbh->do( "DECLARE cron_bill_cursor CURSOR FOR $select" )
+      or die $cursor_dbh->errstr;
+  }
 
   while ( 1 ) {
 
-    my $sth = $cursor_dbh->prepare('FETCH 100 FROM cron_bill_cursor'); #mysql?
+    my $sql = (driver_name =~ /^mysql/)
+      ? $select
+      : 'FETCH 100 FROM cron_bill_cursor';
+
+    my $sth = $cursor_dbh->prepare($sql);
 
     $sth->execute or die $sth->errstr;
 
@@ -120,6 +126,8 @@
 
     }
 
+    last if driver_name =~ /^mysql/;
+
   }
 
   $cursor_dbh->commit or die $cursor_dbh->errstr;

Index: notify.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Cron/notify.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -d -r1.11 -r1.12
--- notify.pm	1 Sep 2010 18:44:15 -0000	1.11
+++ notify.pm	19 Oct 2010 00:32:10 -0000	1.12
@@ -37,7 +37,7 @@
                 and 0 < ( select count(*) from part_pkg_option
                             where part_pkg.pkgpart = part_pkg_option.pkgpart
                               and part_pkg_option.optionname = 'recur_notify'
-                              and CAST( part_pkg_option.optionvalue AS INTEGER ) > 0
+                              and CAST( part_pkg_option.optionvalue AS $integer ) > 0
                               and 0 <= ( $time
                                          + CAST( part_pkg_option.optionvalue AS $integer )
                                            * 86400
@@ -64,7 +64,7 @@
       0 = ( select count(*) from cust_pkg_option
               where cust_pkg.pkgnum = cust_pkg_option.pkgnum
                 and cust_pkg_option.optionname = 'impending_recur_notification_sent'
-                and CAST( cust_pkg_option.optionvalue AS INTEGER ) = 1
+                and CAST( cust_pkg_option.optionvalue AS $integer ) = 1
           )
 END
   



More information about the freeside-commits mailing list