Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r18896: minor bug on dev servers (where DBI Rais...

Committer: gariev
minor bug on dev servers (where DBI RaiseError=1) - can't save empty list of URLs (http://www.lj-9.bulyon.local/customize/options.bml?group=linkslist)
U   trunk/cgi-bin/ljlinks.pl
Modified: trunk/cgi-bin/ljlinks.pl
===================================================================
--- trunk/cgi-bin/ljlinks.pl	2011-04-18 07:48:48 UTC (rev 18895)
+++ trunk/cgi-bin/ljlinks.pl	2011-04-18 07:50:34 UTC (rev 18896)
@@ -77,26 +77,23 @@
     my $caplinks = LJ::get_cap($u, "userlinks");
     $numlinks = $caplinks if $numlinks > $caplinks;
 
-    # build insert query
-    my (@bind, @vals);
-    foreach my $ct (1..$numlinks) {
-        my $it = $linkobj->[$ct-1];
-
-        # journalid, ordernum, parentnum, url, title
-        push @bind, "(?,?,?,?,?)";
-        push @vals, ($u->{'userid'}, $ct, 0, $it->{'url'}, $it->{'title'});
+    if ($numlinks) {
+        # build insert query
+        my (@bind, @vals);
+        foreach my $ct (1..$numlinks) {
+            my $it = $linkobj->[$ct-1];
+            # journalid, ordernum, parentnum, url, title
+            push @bind, "(?,?,?,?,?)";
+            push @vals, ($u->{'userid'}, $ct, 0, $it->{'url'}, $it->{'title'});
+        }
+        my $binds = join(",", @bind);
+        $u->do("INSERT INTO links (journalid, ordernum, parentnum, url, title) VALUES $binds", undef, @vals);
     }
 
     # invalidate memcache
     my $memkey = [$u->{'userid'}, "linkobj:$u->{'userid'}"];
     LJ::MemCache::delete($memkey);
 
-    # insert into database
-    {
-        local $" = ",";
-        return $u->do("INSERT INTO links (journalid, ordernum, parentnum, url, title) " .
-                      "VALUES @bind", undef, @vals);
-    }
 }
 
 sub make_linkobj_from_form

Tags: gariev, livejournal, pl
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments