[Cpan-forum-commit] rev 314 - in trunk: . lib/CPAN lib/CPAN/Forum lib/CPAN/Forum/DB lib/CPAN/Forum/RM

svn at pti.co.il svn at pti.co.il
Thu Aug 2 09:24:46 EEST 2007


Author: gabor
Date: 2007-08-02 09:24:46 +0300 (Thu, 02 Aug 2007)
New Revision: 314

Modified:
   trunk/
   trunk/lib/CPAN/Forum.pm
   trunk/lib/CPAN/Forum/DB/Subscriptions_all.pm
   trunk/lib/CPAN/Forum/DB/Subscriptions_pauseid.pm
   trunk/lib/CPAN/Forum/DBI.pm
   trunk/lib/CPAN/Forum/RM/Subscriptions.pm
Log:
managing subscription per PAUSEID in mypan works now



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4370
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
   + 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4371
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752

Modified: trunk/lib/CPAN/Forum/DB/Subscriptions_all.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Subscriptions_all.pm	2007-08-02 06:24:27 UTC (rev 313)
+++ trunk/lib/CPAN/Forum/DB/Subscriptions_all.pm	2007-08-02 06:24:46 UTC (rev 314)
@@ -36,35 +36,6 @@
     return ($sql, @values);
 }
 
-sub _prep_where {
-    my ($self, $args) = @_;
-    #Carp::cluck (Data::Dumper->Dump([$args], ['args']));
-
-    my @fields = keys %$args;
-    my $where = join " AND ", map {"$_=?"} @fields;
-    my %args = %$args;
-    return ($where, @args{@fields}); 
-}
-
-sub _prep_set {
-    my ($self, $args) = @_;
-    my @fields = keys %$args;
-
-    my $where = join ", ", map {"$_=?"} @fields;
-    my %args = %$args;
-    return ($where, @args{@fields}); 
-    #return ($where, @{ $args->{@fields} }); 
-}
-
-sub _prep_insert {
-    my ($self, $args) = @_;
-
-    my @fields = keys %$args;
-    my $fields = join ", ", @fields;
-    my $placeholders = join ", ", (("?") x scalar @fields);
-    return ($fields, $placeholders, @{ $args->{@fields} }); 
-}
-
 sub complex_update {
     my ($self, @args) = @_;
     $self->_complex_update(@args, 'subscriptions_all');

Modified: trunk/lib/CPAN/Forum/DB/Subscriptions_pauseid.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Subscriptions_pauseid.pm	2007-08-02 06:24:27 UTC (rev 313)
+++ trunk/lib/CPAN/Forum/DB/Subscriptions_pauseid.pm	2007-08-02 06:24:46 UTC (rev 314)
@@ -28,8 +28,12 @@
     # check if keys of args is uid 
     my @fields = keys %args;
     my $where = join " AND ", map {"$_=?"} @fields;
-    my $sql = "SELECT subscriptions_pauseid.id pasuseid, uid, allposts, starters, followups, announcements,
-        authors.pauseid pauseid_name FROM subscriptions_pauseid, authors WHERE authors.id=subscriptions_pauseid.pauseid";
+    $where =~ s/\bpauseid\b/subscriptions_pauseid.pauseid/;  # nasty workaround?
+    my $sql = "SELECT subscriptions_pauseid.pauseid pauseid, uid, 
+                      allposts, starters, followups, announcements,
+                      authors.pauseid pauseid_name
+               FROM subscriptions_pauseid, authors 
+               WHERE authors.id=subscriptions_pauseid.pauseid";
     if ($where) {
         $sql .= " AND $where";
     }
@@ -38,7 +42,7 @@
 
 sub complex_update {
     my ($self, @args) = @_;
-    $self->_complex_update(@args, 'subscriptions');
+    $self->_complex_update(@args, 'subscriptions_pauseid');
 }
 
 

Modified: trunk/lib/CPAN/Forum/DBI.pm
===================================================================
--- trunk/lib/CPAN/Forum/DBI.pm	2007-08-02 06:24:27 UTC (rev 313)
+++ trunk/lib/CPAN/Forum/DBI.pm	2007-08-02 06:24:46 UTC (rev 314)
@@ -59,6 +59,7 @@
 sub _fetch_arrayref_of_hashes {
     my ($self, $sql, @args) = @_;
 
+    $CPAN::Forum::logger->debug("SQL:$sql, " . Data::Dumper->Dump([\@args], ['args'])); 
     my $dbh = CPAN::Forum::DBI::db_Main();
     my $sth = $dbh->prepare($sql);
     $sth->execute(@args);
@@ -71,6 +72,7 @@
 sub _fetch_single_hashref {
     my ($self, $sql, @args) = @_;
 
+    $CPAN::Forum::logger->debug("SQL:$sql, " . Data::Dumper->Dump([\@args], ['args'])); 
     my $dbh = CPAN::Forum::DBI::db_Main();
     my $sth = $dbh->prepare($sql);
     $sth->execute(@args);
@@ -157,6 +159,9 @@
     my ($fields, $placeholders, @values) = $self->_prep_insert($args);
     my $sql = "INSERT INTO $table ($fields) VALUES($placeholders)";
     my $dbh = CPAN::Forum::DBI::db_Main();
+    $CPAN::Forum::logger->debug("SQL:$sql, " 
+            . Data::Dumper->Dump([\@values], ['values'])
+            ); 
     $dbh->do($sql, undef, @values);
     return;
 }    
@@ -165,12 +170,16 @@
 sub update {
     my ($self, $table, $args, $data) = @_;
     # check if $table is one of the subscription tables?
-    my ($where, @values)   = $self->_prep_where($args);
+    my ($where, @where_values)   = $self->_prep_where($args);
     Carp::croak("") if not $where;
     my ($set, @new_values) = $self->_prep_set($data);
     my $sql = "UPDATE $table SET $set WHERE $where";
     my $dbh = CPAN::Forum::DBI::db_Main();
-    $dbh->do($sql, undef, @new_values, @values);
+    $CPAN::Forum::logger->debug("SQL:$sql, " 
+            . Data::Dumper->Dump([\@new_values], ['new_values'])
+            . Data::Dumper->Dump([\@where_values], ['where_value'])
+            ); 
+    $dbh->do($sql, undef, @new_values, @where_values);
     return;
 }
 
@@ -186,5 +195,37 @@
     return;
 }
 
+sub _prep_where {
+    my ($self, $args) = @_;
+    #Carp::cluck (Data::Dumper->Dump([$args], ['args']));
+
+    my @fields = keys %$args;
+    my $where = join " AND ", map {"$_=?"} @fields;
+    my %args = %$args;
+    return ($where, @args{@fields}); 
+}
+
+sub _prep_set {
+    my ($self, $args) = @_;
+    my @fields = keys %$args;
+
+    my $where = join ", ", map {"$_=?"} @fields;
+    my %args = %$args;
+    return ($where, @args{@fields}); 
+    #return ($where, @{ $args->{@fields} }); 
+}
+
+sub _prep_insert {
+    my ($self, $args) = @_;
+
+    my @fields = keys %$args;
+    my $fields = join ", ", @fields;
+    my $placeholders = join ", ", (("?") x scalar @fields);
+    my %args = %$args;
+    return ($fields, $placeholders, @args{@fields}); 
+    #return ($fields, $placeholders, @{ $args->{@fields} }); 
+}
+
+
 1;
 

Modified: trunk/lib/CPAN/Forum/RM/Subscriptions.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Subscriptions.pm	2007-08-02 06:24:27 UTC (rev 313)
+++ trunk/lib/CPAN/Forum/RM/Subscriptions.pm	2007-08-02 06:24:46 UTC (rev 314)
@@ -155,12 +155,14 @@
 
     foreach my $gid (@gids) {
         my ($on, $data) = $self->_get_subs($gid);
+        $self->log->debug("Processing GID: '$gid'");
 
         if ($gid eq "_all") {
             $self->log->debug("Subscription_all: '$uid', '$on', " . Data::Dumper->Dump([$data], ['data']));
-            CPAN::Forum::DB::Subscriptions_all->complex_update({uid => $uid}, $on, $data);
+            CPAN::Forum::DB::Subscriptions_all->complex_update({uid => $uid}, $on, $data); # SQL
         } elsif ($gid =~ /^_(\d+)$/) {
             my $pauseid = $1;
+            $self->log->debug("Subscription_pauseid: pauseid='$pauseid', uid='$uid', on='$on', " . Data::Dumper->Dump([$data], ['data']));
             CPAN::Forum::DB::Subscriptions_pauseid->complex_update({pauseid => $pauseid, uid => $uid}, $on, $data); # SQL
         } elsif ($gid =~ /^(\d+)$/) {
             CPAN::Forum::DB::Subscriptions->complex_update({gid => $gid, uid => $uid}, $on, $data); #SQL 

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2007-08-02 06:24:27 UTC (rev 313)
+++ trunk/lib/CPAN/Forum.pm	2007-08-02 06:24:46 UTC (rev 314)
@@ -28,6 +28,15 @@
     "ERR open_code_without_closing" => "open <code> tag without closing tag",
 );
 
+our $logger;
+$SIG{__WARN__} = sub {
+    if ($logger) {
+        $logger->warning($_[0]);
+    } else {
+        print STDERR $_[0];
+    }
+};
+
 =head1 NAME
 
 CPAN::Forum - Web forum application to discuss CPAN modules
@@ -438,6 +447,7 @@
     );
 
     $self->log->debug("--- START ---");
+    $CPAN::Forum::logger = $self->log;
     
 
     $self->log->debug("Cookie received: "  . ($self->query->cookie($cookiename) || "") );



More information about the Cpan-forum-commit mailing list