[freeside-commits] branch FREESIDE_3_BRANCH updated. 704df08c7f81c0ac0e828362f0b1304225757374

Ivan ivan at 420.am
Fri May 30 14:04:12 PDT 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  704df08c7f81c0ac0e828362f0b1304225757374 (commit)
       via  92f4d4407513140d5c78a689f340e5f4c1ffcbe5 (commit)
      from  0ea23112cfa0d82738b0f08d60d90579721b7524 (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 704df08c7f81c0ac0e828362f0b1304225757374
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri May 30 14:04:10 2014 -0700

    MySQL support, RT#28895

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 71bdec9..95de553 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3161,16 +3161,16 @@ sub tables_hashref {
 
     'tower_sector' => {
       'columns' => [
-        'sectornum',   'serial',     '',      '', '', '',
-        'towernum',       'int',     '',      '', '', '',
-        'sectorname', 'varchar',     '', $char_d, '', '',
-        'ip_addr',    'varchar', 'NULL',      15, '', '',
-        'height',     'decimal', 'NULL',      '', '', '', 
-        'freq_mhz',       'int', 'NULL',      '', '', '',
-        'direction',      'int', 'NULL',      '', '', '',
-        'width',          'int', 'NULL',      '', '', '',
+        'sectornum',     'serial',     '',      '', '', '',
+        'towernum',         'int',     '',      '', '', '',
+        'sectorname',   'varchar',     '', $char_d, '', '',
+        'ip_addr',      'varchar', 'NULL',      15, '', '',
+        'height',       'decimal', 'NULL',      '', '', '', 
+        'freq_mhz',         'int', 'NULL',      '', '', '',
+        'direction',        'int', 'NULL',      '', '', '',
+        'width',            'int', 'NULL',      '', '', '',
         #downtilt etc? rfpath has profile files for devices/antennas you upload?
-        'range',      'decimal', 'NULL',      '', '', '',  #?
+        'sector_range', 'decimal', 'NULL',      '', '', '',  #?
       ],
       'primary_key' => 'sectornum',
       'unique'      => [ [ 'towernum', 'sectorname' ], [ 'ip_addr' ], ],
diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm
index 3c972d0..7339d74 100644
--- a/FS/FS/TicketSystem.pm
+++ b/FS/FS/TicketSystem.pm
@@ -331,16 +331,24 @@ sub _upgrade_data {
     }
   }
 
-  #Pg-specific 
-  my $cve_2013_3373_sql = q(
-    UPDATE Tickets SET Subject = REPLACE(Subject,E'\n','')
-  );
-  #need this for mysql
-  #UPDATE Tickets SET Subject = REPLACE(Subject,'\n','');
-
-  my $cve_2013_3373_sth = $dbh->prepare( $cve_2013_3373_sql)
-    or die $dbh->errstr;
-  $cve_2013_3373_sth->execute or die $cve_2013_3373_sth->errstr;
+  my $cve_2013_3373_sql = '';
+  if ( driver_name =~ /^Pg/i ) {
+    $cve_2013_3373_sql = q(
+      UPDATE Tickets SET Subject = REPLACE(Subject,E'\n','')
+    );
+  } elsif ( driver_name =~ /^mysql/i ) {
+    $cve_2013_3373_sql = q(
+      UPDATE Tickets SET Subject = REPLACE(Subject,'\n','');
+    );
+  } else {
+    warn "WARNING: Don't know how to update RT Ticket Subjects for your database driver for CVE-2013-3373";
+  }
+  if ( $cve_2013_3373_sql ) {
+    my $cve_2013_3373_sth = $dbh->prepare($cve_2013_3373_sql)
+      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');
diff --git a/FS/FS/tower_sector.pm b/FS/FS/tower_sector.pm
index 70642fb..4a6525e 100644
--- a/FS/FS/tower_sector.pm
+++ b/FS/FS/tower_sector.pm
@@ -112,7 +112,7 @@ sub check {
     || $self->ut_numbern('freq_mhz')
     || $self->ut_numbern('direction')
     || $self->ut_numbern('width')
-    || $self->ut_floatn('range')
+    || $self->ut_floatn('sector_range')
   ;
   return $error if $error;
 
diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade
index c3d070e..e74abbf 100755
--- a/FS/bin/freeside-upgrade
+++ b/FS/bin/freeside-upgrade
@@ -94,10 +94,18 @@ if ( dbdef->table('areacode') and
 }
 
 if ( dbdef->table('upgrade_journal') ) {
-  push @bugfix, "SELECT SETVAL( 'upgrade_journal_upgradenum_seq',
-                                ( SELECT MAX(upgradenum) FROM upgrade_journal )
-                              )
-                ";
+  if ( driver_name =~ /^Pg/i ) {
+    push @bugfix, "
+      SELECT SETVAL( 'upgrade_journal_upgradenum_seq',
+                     ( SELECT MAX(upgradenum) FROM upgrade_journal )
+                   )
+    ";
+  } elsif ( driver_name =~ /^mysql/i ) {
+    push @bugfix, "
+       ALTER TABLE upgrade_journal AUTO_INCREMENT =
+                   ( ( SELECT MAX(upgradenum) FROM upgrade_journal ) + 1 )
+    ";
+  }
 }
 
 if ( $DRY_RUN ) {
diff --git a/httemplate/edit/process/tower.html b/httemplate/edit/process/tower.html
index bbfc1a6..02362db 100644
--- a/httemplate/edit/process/tower.html
+++ b/httemplate/edit/process/tower.html
@@ -2,6 +2,9 @@
     table       => 'tower',
     viewall_dir => 'browse',
     process_o2m => { 'table'  => 'tower_sector',
-                     'fields' => [qw( sectorname ip_addr height freq_mhz direction width range )],
+                     'fields' => [qw(
+                       sectorname ip_addr height freq_mhz direction width
+                       sector_range
+                     )],
                    },
 &>
diff --git a/httemplate/edit/tower.html b/httemplate/edit/tower.html
index 00c9add..fa3838d 100644
--- a/httemplate/edit/tower.html
+++ b/httemplate/edit/tower.html
@@ -37,7 +37,10 @@
 my $m2_error_callback = sub { # reconstruct the list
   my ($cgi, $object) = @_;
 
-  my @fields = qw( sectorname ip_addr height freq_mhz direction width range );
+  my @fields = qw(
+    sectorname ip_addr height freq_mhz direction width sector_range
+  );
+
   map {
     my $k = $_;
     new FS::tower_sector {
diff --git a/httemplate/elements/tower_sector.html b/httemplate/elements/tower_sector.html
index 406895e..151d3ba 100644
--- a/httemplate/elements/tower_sector.html
+++ b/httemplate/elements/tower_sector.html
@@ -51,13 +51,13 @@ if ( $curr_value ) {
 my %size = ( 'title' => 12 );
 
 tie my %label, 'Tie::IxHash',
-  'sectorname' => 'Name',
-  'ip_addr'    => 'IP Address',
-  'height'     => 'Height',
-  'freq_mhz'   => 'Freq. (MHz)',
-  'direction'  => 'Direction', # or a button to set these to 0 for omni
-  'width'      => 'Width',     #
-  'range'      => 'Range',
+  'sectorname'   => 'Name',
+  'ip_addr'      => 'IP Address',
+  'height'       => 'Height',
+  'freq_mhz'     => 'Freq. (MHz)',
+  'direction'    => 'Direction', # or a button to set these to 0 for omni
+  'width'        => 'Width',     #
+  'sector_range' => 'Range',
 ;
 
 my @fields = keys %label;

commit 92f4d4407513140d5c78a689f340e5f4c1ffcbe5
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat May 3 14:01:26 2014 -0700

    optimize event queries, RT#28978, possible MySQL band-aid, RT#28978

diff --git a/FS/FS/part_event_condition.pm b/FS/FS/part_event_condition.pm
index 78aa3b1..b51c6b9 100644
--- a/FS/FS/part_event_condition.pm
+++ b/FS/FS/part_event_condition.pm
@@ -253,7 +253,6 @@ B<where_conditions_sql>.
 
 sub join_conditions_sql {
   my ( $class, $eventtable ) = @_;
-  my %conditions = $class->conditions( $eventtable );
 
   join(' ',
     map {
@@ -262,7 +261,8 @@ sub join_conditions_sql {
           "       AND cond_$_.conditionname = ". dbh->quote($_).
           "     )";
         }
-        keys %conditions
+      map $_->[0], $class->_where_conditions( $eventtable ) #, %options )
+
   );
 
 }
@@ -280,27 +280,38 @@ as passed to freeside-daily), as a UNIX timestamp.
 sub where_conditions_sql {
   my ( $class, $eventtable, %options ) = @_;
 
+  join(' AND ',
+         map { my $conditionname = $_->[0];
+               my $sql = $_->[1];
+               "( cond_$conditionname.conditionname IS NULL OR $sql )";
+             }
+           $class->_where_conditions( $eventtable, %options )
+      );
+}
+
+sub _where_conditions {
+  my ( $class, $eventtable, %options ) = @_;
+
   my $time = $options{'time'};
 
   my %conditions = $class->conditions( $eventtable );
 
-  my $where = join(' AND ',
+  grep { $_->[1] !~ /^\s*true\s*$/i
+         || $conditions{ $_->[0] }->{order_sql}
+       }
     map {
           my $conditionname = $_;
           my $coderef = $conditions{$conditionname}->{condition_sql};
+          #die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE';
           my $sql = &$coderef( $eventtable, 'time'        => $time,
                                             'driver_name' => driver_name(),
                              );
-          die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE';
-          "( cond_$conditionname.conditionname IS NULL OR $sql )";
+          [ $_, $sql ];
         }
-        grep { my $cond = $_;
-               ! grep { $_ eq $cond } @SKIP_CONDITION_SQL
-             }
-             keys %conditions
-  );
-
-  $where;
+      grep { my $cond = $_;
+             ! grep { $_ eq $cond } @SKIP_CONDITION_SQL
+           }
+        keys %conditions;
 }
 
 =item order_conditions_sql [ EVENTTABLE ]

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Schema.pm                       |   18 ++++++++--------
 FS/FS/TicketSystem.pm                 |   28 +++++++++++++++++---------
 FS/FS/part_event_condition.pm         |   35 +++++++++++++++++++++-----------
 FS/FS/tower_sector.pm                 |    2 +-
 FS/bin/freeside-upgrade               |   16 +++++++++++---
 httemplate/edit/process/tower.html    |    5 +++-
 httemplate/edit/tower.html            |    5 +++-
 httemplate/elements/tower_sector.html |   14 ++++++------
 8 files changed, 78 insertions(+), 45 deletions(-)




More information about the freeside-commits mailing list