afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-09-05 02:35 pm

[dw-free] remove support for legacy dversions

[commit: http://hg.dwscoalition.org/dw-free/rev/00706993500e]

http://bugs.dwscoalition.org/show_bug.cgi?id=1740

Anything below dversion 8 can go. (code cleanup)

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/Apache/LiveJournal.pm
  • cgi-bin/LJ/Poll.pm
  • cgi-bin/LJ/Poll/Question.pm
  • cgi-bin/LJ/User.pm
  • cgi-bin/LJ/Userpic.pm
  • cgi-bin/ljlib.pl
  • cgi-bin/ljmemories.pl
  • cgi-bin/ljuserpics.pl
  • htdocs/editpics.bml
--------------------------------------------------------------------------------
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/Apache/LiveJournal.pm
--- a/cgi-bin/Apache/LiveJournal.pm	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/Apache/LiveJournal.pm	Sat Sep 05 14:35:14 2009 +0000
@@ -49,11 +49,6 @@ my %REDIR;
 my %REDIR;
 
 # Mapping of MIME types to image types understood by the blob functions.
-my %MimeTypeMap = (
-    'image/gif' => 'gif',
-    'image/jpeg' => 'jpg',
-    'image/png' => 'png',
-);
 my %MimeTypeMapd6 = (
     'G' => 'gif',
     'J' => 'jpg',
@@ -1174,7 +1169,7 @@ sub userpic_content
 
         # Now ask the blob lib for the path to send to the reproxy
         eval { LJ::Blob->can("autouse"); };
-        my $fmt = ($u->{'dversion'} > 6) ? $MimeTypeMapd6{ $pic->{fmt} } : $MimeTypeMap{ $pic->{contenttype} };
+        my $fmt = $MimeTypeMapd6{ $pic->{fmt} };
         my $path = LJ::Blob::get_rel_path( $root, $u, "userpic", $fmt, $picid );
 
         $r->headers_out->{'X-REPROXY-FILE'} = $path;
@@ -1209,7 +1204,7 @@ sub userpic_content
 
         if ($LJ::USERPIC_BLOBSERVER) {
             eval { LJ::Blob->can("autouse"); };
-            my $fmt = ($u->{'dversion'} > 6) ? $MimeTypeMapd6{ $pic->{fmt} } : $MimeTypeMap{ $pic->{contenttype} };
+            my $fmt = $MimeTypeMapd6{ $pic->{fmt} };
             $data = LJ::Blob::get($u, "userpic", $fmt, $picid);
         }
 
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/LJ/Poll.pm
--- a/cgi-bin/LJ/Poll.pm	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/LJ/Poll.pm	Sat Sep 05 14:35:14 2009 +0000
@@ -81,27 +81,17 @@ sub create {
         or die "Invalid journalid $journalid";
 
     my $dbh = LJ::get_db_writer();
-    my $sth;
 
-    if ($u->polls_clustered) {
-        # poll stored on user cluster
-        $u->do("INSERT INTO poll2 (journalid, pollid, posterid, whovote, whoview, name, ditemid) " .
-               "VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
-               $journalid, $pollid, $posterid, $whovote, $whoview, $name, $ditemid);
-        die $u->errstr if $u->err;
+    $u->do( "INSERT INTO poll2 (journalid, pollid, posterid, whovote, whoview, name, ditemid) " .
+            "VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
+            $journalid, $pollid, $posterid, $whovote, $whoview, $name, $ditemid );
+    die $u->errstr if $u->err;
 
-        # made poll, insert global pollid->journalid mapping into global pollowner map
-        $dbh->do("INSERT INTO pollowner (journalid, pollid) VALUES (?, ?)", undef,
-                 $journalid, $pollid);
+    # made poll, insert global pollid->journalid mapping into global pollowner map
+    $dbh->do( "INSERT INTO pollowner (journalid, pollid) VALUES (?, ?)", undef,
+              $journalid, $pollid );
 
-        die $dbh->errstr if $dbh->err;
-    } else {
-        # poll stored on global
-        $dbh->do("INSERT INTO poll (pollid, itemid, journalid, posterid, whovote, whoview, name) " .
-                 "VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
-                 $pollid, $ditemid, $journalid, $posterid, $whovote, $whoview, $name);
-        die $dbh->errstr if $dbh->err;
-    }
+    die $dbh->errstr if $dbh->err;
 
     ## start inserting poll questions
     my $qnum = 0;
@@ -109,32 +99,19 @@ sub create {
     foreach my $q (@$questions) {
         $qnum++;
 
-        if ($u->polls_clustered) {
-            $u->do("INSERT INTO pollquestion2 (journalid, pollid, pollqid, sortorder, type, opts, qtext) " .
-                        "VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
-                        $journalid, $pollid, $qnum, $qnum, $q->{'type'}, $q->{'opts'}, $q->{'qtext'});
-            die $u->errstr if $u->err;
-        } else {
-            $dbh->do("INSERT INTO pollquestion (pollid, pollqid, sortorder, type, opts, qtext) " .
-                          "VALUES (?, ?, ?, ?, ?, ?)", undef,
-                          $pollid, $qnum, $qnum, $q->{'type'}, $q->{'opts'}, $q->{'qtext'});
-            die $dbh->errstr if $dbh->err;
-        }
+        $u->do( "INSERT INTO pollquestion2 (journalid, pollid, pollqid, sortorder, type, opts, qtext) " .
+                "VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
+                $journalid, $pollid, $qnum, $qnum, $q->{'type'}, $q->{'opts'}, $q->{'qtext'} );
+        die $u->errstr if $u->err;
 
         ## start inserting poll items
         my $inum = 0;
         foreach my $it (@{$q->{'items'}}) {
             $inum++;
 
-            if ($u->polls_clustered) {
-                $u->do("INSERT INTO pollitem2 (journalid, pollid, pollqid, pollitid, sortorder, item) " .
-                       "VALUES (?, ?, ?, ?, ?, ?)", undef, $journalid, $pollid, $qnum, $inum, $inum, $it->{'item'});
-                die $u->errstr if $u->err;
-            } else {
-                $dbh->do("INSERT INTO pollitem (pollid, pollqid, pollitid, sortorder, item) " .
-                         "VALUES (?, ?, ?, ?, ?)", undef, $pollid, $qnum, $inum, $inum, $it->{'item'});
-                die $dbh->errstr if $dbh->err;
-            }
+            $u->do( "INSERT INTO pollitem2 (journalid, pollid, pollqid, pollitid, sortorder, item) " .
+                    "VALUES (?, ?, ?, ?, ?, ?)", undef, $journalid, $pollid, $qnum, $inum, $inum, $it->{'item'} );
+            die $u->errstr if $u->err;
         }
         ## end inserting poll items
 
@@ -581,20 +558,11 @@ sub _load {
             or die "Invalid journalid $journalid";
 
         # double-check to make sure we are consulting the right table
-        if ($u->polls_clustered) {
-            # clustered poll
-            $row = $u->selectrow_hashref("SELECT pollid, journalid, ditemid, " .
-                                         "posterid, whovote, whoview, name, status " .
-                                         "FROM poll2 WHERE pollid=? " .
-                                         "AND journalid=?", undef, $self->pollid, $journalid);
-            die $u->errstr if $u->err;
-        } else {
-            # unclustered poll
-            $row = $dbr->selectrow_hashref("SELECT pollid, itemid, journalid, " .
-                                           "posterid, whovote, whoview, name, status " .
-                                           "FROM poll WHERE pollid=?", undef, $self->pollid);
-            die $dbr->errstr if $dbr->err;
-        }
+        $row = $u->selectrow_hashref( "SELECT pollid, journalid, ditemid, " .
+                                      "posterid, whovote, whoview, name, status " .
+                                      "FROM poll2 WHERE pollid=? " .
+                                      "AND journalid=?", undef, $self->pollid, $journalid );
+        die $u->errstr if $u->err;
     }
 
     return undef unless $row;
@@ -632,17 +600,9 @@ sub close_poll {
 
     my $dbh = LJ::get_db_writer();
 
-    if ($u->polls_clustered) {
-        # poll stored on user cluster
-        $u->do("UPDATE poll2 SET status='X' where pollid=? AND journalid=?",
-               undef, $self->pollid, $self->journalid);
-        die $u->errstr if $u->err;
-    } else {
-        # poll stored on global
-        $dbh->do("UPDATE poll SET status='X' where pollid=? ",
-                 undef, $self->pollid);
-        die $dbh->errstr if $dbh->err;
-    }
+    $u->do( "UPDATE poll2 SET status='X' where pollid=? AND journalid=?",
+            undef, $self->pollid, $self->journalid );
+    die $u->errstr if $u->err;
 
     # poll status has changed
     $self->_remove_from_memcache;
@@ -663,17 +623,9 @@ sub open_poll {
 
     my $dbh = LJ::get_db_writer();
 
-    if ($u->polls_clustered) {
-        # poll stored on user cluster
-        $u->do("UPDATE poll2 SET status='' where pollid=? AND journalid=?",
-               undef, $self->pollid, $self->journalid);
-        die $u->errstr if $u->err;
-    } else {
-        # poll stored on global
-        $dbh->do("UPDATE poll SET status='' where pollid=? ",
-                 undef, $self->pollid);
-        die $dbh->errstr if $dbh->err;
-    }
+    $u->do( "UPDATE poll2 SET status='' where pollid=? AND journalid=?",
+            undef, $self->pollid, $self->journalid );
+    die $u->errstr if $u->err;
 
     # poll status has changed
     $self->_remove_from_memcache;
@@ -737,11 +689,6 @@ sub journal {
     return LJ::load_userid($self->journalid);
 }
 
-sub is_clustered {
-    my $self = shift;
-    return $self->journal->polls_clustered;
-}
-
 # return true if poll is closed
 sub is_closed {
     my $self = shift;
@@ -794,19 +741,12 @@ sub question {
 
 # returns the time that the given user answered the given poll
 sub get_time_user_submitted {
-    my ($self, $u) = @_;
+    my ( $self, $u ) = @_;
 
-    my $time;
-    if ($self->is_clustered) {
-        $time = $self->journal->selectrow_array('SELECT datesubmit FROM pollsubmission2 '.
-                                                'WHERE pollid=? AND userid=? AND journalid=?', undef, $self->pollid, $u->userid, $self->journalid);
-    } else {
-        my $dbr = LJ::get_db_reader();
-        $time = $dbr->selectrow_array('SELECT datesubmit FROM pollsubmission '.
-                                      'WHERE pollid=? AND userid=?', undef, $self->pollid, $u->userid);
-    }
+    return $self->journal->selectrow_array( 'SELECT datesubmit FROM pollsubmission2 '.
+                                            'WHERE pollid=? AND userid=? AND journalid=?',
+                                            undef, $self->pollid, $u->userid, $self->journalid );
 
-    return $time;
 }
 
 # expects a fake poll object (doesn't have to have pollid) and
@@ -926,16 +866,11 @@ sub render {
 
     my %preval;
 
-    if ($do_form) {
-        if ($self->is_clustered) {
-            $sth = $self->journal->prepare("SELECT pollqid, value FROM pollresult2 WHERE pollid=? AND userid=? AND journalid=?");
-            $sth->execute($pollid, $remote->{'userid'}, $self->journalid);
-        } else {
-            $sth = $dbr->prepare("SELECT pollqid, value FROM pollresult WHERE pollid=? AND userid=?");
-            $sth->execute($pollid, $remote->{'userid'});
-        }
+    if ( $do_form ) {
+        $sth = $self->journal->prepare( "SELECT pollqid, value FROM pollresult2 WHERE pollid=? AND userid=? AND journalid=?" );
+        $sth->execute( $pollid, $remote->userid, $self->journalid );
 
-        while (my ($qid, $value) = $sth->fetchrow_array) {
+        while ( my ( $qid, $value ) = $sth->fetchrow_array ) {
             $preval{$qid} = $value;
         }
 
@@ -967,15 +902,9 @@ sub render {
         $ret .= "[ <a href='$LJ::SITEROOT/poll/?id=$pollid&amp;mode=results'>" . BML::ml( 'poll.seeresults' ) . "</a> ]  ";
     } elsif ( $mode eq 'results' ) {
         #include number of participants
-        my $sth = "";
-        if ($self->is_clustered) {
-            $sth = $self->journal->prepare("SELECT count(DISTINCT userid) FROM pollresult2 WHERE pollid=? AND journalid=?");
-            $sth->execute($pollid, $self->journalid);
-        } else {
-            $sth = $dbr->prepare("SELECT count(DISTINCT userid) FROM pollresult WHERE pollid=?");
-            $sth->execute($pollid);
-        }
-        my ($participants) = $sth->fetchrow_array;
+        my $sth = $self->journal->prepare( "SELECT count(DISTINCT userid) FROM pollresult2 WHERE pollid=? AND journalid=?" );
+        $sth->execute( $pollid, $self->journalid );
+        my ( $participants ) = $sth->fetchrow_array;
         $ret .= LJ::Lang::ml('poll.participants', { 'total' => $participants });
         $ret .= "<br />\n";
         # change vote link
@@ -996,16 +925,11 @@ sub render {
         my ($valcount, $valmean, $valstddev, $valmedian);
         if ($q->type eq "scale") {
             # get stats
-            if ($self->is_clustered) {
-                $sth = $self->journal->prepare("SELECT COUNT(*), AVG(value), STDDEV(value) FROM pollresult2 " .
-                                               "WHERE pollid=? AND pollqid=? AND journalid=?");
-                $sth->execute($pollid, $qid, $self->journalid);
-            } else {
-                $sth = $dbr->prepare("SELECT COUNT(*), AVG(value), STDDEV(value) FROM pollresult WHERE pollid=? AND pollqid=?");
-                $sth->execute($pollid, $qid);
-            }
+            $sth = $self->journal->prepare( "SELECT COUNT(*), AVG(value), STDDEV(value) FROM pollresult2 " .
+                                            "WHERE pollid=? AND pollqid=? AND journalid=?" );
+            $sth->execute( $pollid, $qid, $self->journalid );
 
-            ($valcount, $valmean, $valstddev) = $sth->fetchrow_array;
+            ( $valcount, $valmean, $valstddev ) = $sth->fetchrow_array;
 
             # find median:
             $valmedian = 0;
@@ -1018,15 +942,10 @@ sub render {
                 $mid = int(($valcount+1)/2);
                 my $skip = $mid-1;
 
-                if ($self->is_clustered) {
-                    $sth = $self->journal->prepare("SELECT value FROM pollresult2 WHERE pollid=? AND pollqid=? AND journalid=? " .
-                                         "ORDER BY value+0 LIMIT $skip,$fetch");
-                    $sth->execute($pollid, $qid, $self->journalid);
-                } else {
-                    $sth = $dbr->prepare("SELECT value FROM pollresult WHERE pollid=? AND pollqid=? " .
-                                         "ORDER BY value+0 LIMIT $skip,$fetch");
-                    $sth->execute($pollid, $qid);
-                }
+                $sth = $self->journal->prepare(
+                    "SELECT value FROM pollresult2 WHERE pollid=? AND pollqid=? AND journalid=? " .
+                    "ORDER BY value+0 LIMIT $skip,$fetch" );
+                $sth->execute( $pollid, $qid, $self->journalid );
 
                 while (my ($v) = $sth->fetchrow_array) {
                     $valmedian += $v;
@@ -1050,13 +969,8 @@ sub render {
 
             ### but, if this is a non-text item, and we're showing results, need to load the answers:
             if ($q->type ne "text") {
-                if ($self->is_clustered) {
-                    $sth = $self->journal->prepare("SELECT value FROM pollresult2 WHERE pollid=? AND pollqid=? AND journalid=?");
-                    $sth->execute($pollid, $qid, $self->journalid);
-                } else {
-                    $sth = $dbr->prepare("SELECT value FROM pollresult WHERE pollid=? AND pollqid=?");
-                    $sth->execute($pollid, $qid);
-                }
+                $sth = $self->journal->prepare( "SELECT value FROM pollresult2 WHERE pollid=? AND pollqid=? AND journalid=?" );
+                $sth->execute( $pollid, $qid, $self->journalid );
                 while (my ($val) = $sth->fetchrow_array) {
                     $usersvoted++;
                     if ($q->type eq "check") {
@@ -1269,16 +1183,9 @@ sub questions {
         unless $self->pollid;
 
     my @qs = ();
-    my $sth;
 
-    if ($self->is_clustered) {
-        $sth = $self->journal->prepare('SELECT * FROM pollquestion2 WHERE pollid=? AND journalid=?');
-        $sth->execute($self->pollid, $self->journalid);
-    } else {
-        my $dbr = LJ::get_db_reader();
-        $sth = $dbr->prepare('SELECT * FROM pollquestion WHERE pollid=?');
-        $sth->execute($self->pollid);
-    }
+    my $sth = $self->journal->prepare( 'SELECT * FROM pollquestion2 WHERE pollid=? AND journalid=?' );
+    $sth->execute( $self->pollid, $self->journalid );
 
     die $sth->errstr if $sth->err;
 
@@ -1409,15 +1316,9 @@ sub process_submission {
         # if this particular user has already voted, let them change their answer
         my $time = $poll->get_time_user_submitted($remote);
         unless ($time) {
-            my $uids;
-            if ($poll->is_clustered) {
-                $uids = $poll->journal->selectcol_arrayref("SELECT userid FROM pollsubmission2 " .
-                                                           "WHERE journalid = ? AND pollid = ?", undef, $poll->journalid, $poll->pollid);
-            } else {
-                my $dbr = LJ::get_db_reader();
-                $uids = $dbr->selectcol_arrayref("SELECT userid FROM pollsubmission " .
-                                                 "WHERE pollid = ?", undef, $poll->pollid);
-            }
+            my $uids = $poll->journal->selectcol_arrayref( "SELECT userid FROM pollsubmission2 " .
+                                                           "WHERE journalid = ? AND pollid = ?",
+                                                           undef, $poll->journalid, $poll->pollid );
 
             if (@$uids) {
                 my $remote_email = $remote->email_raw;
@@ -1435,9 +1336,6 @@ sub process_submission {
             }
         }
     }
-
-    # Handler needed only for 7th version of Polls.
-    my $dbh = $poll->is_clustered ? undef : LJ::get_db_writer();
 
     ### load all the questions
     my @qs = $poll->questions;
@@ -1459,33 +1357,17 @@ sub process_submission {
         }
         if ($val ne "") {
             $ct++;
-            if ($poll->is_clustered) {
-                $poll->journal->do("REPLACE INTO pollresult2 (journalid, pollid, pollqid, userid, value) VALUES (?, ?, ?, ?, ?)",
-                         undef, $poll->journalid, $pollid, $qid, $remote->userid, $val);
-            } else {
-
-                $dbh->do("REPLACE INTO pollresult (pollid, pollqid, userid, value) VALUES (?, ?, ?, ?)",
-                         undef, $pollid, $qid, $remote->userid, $val);
-            }
+            $poll->journal->do( "REPLACE INTO pollresult2 (journalid, pollid, pollqid, userid, value) VALUES (?, ?, ?, ?, ?)",
+                                undef, $poll->journalid, $pollid, $qid, $remote->userid, $val );
         } else {
-            if ($poll->is_clustered) {
-                $poll->journal->do("DELETE FROM pollresult2 WHERE journalid=? AND pollid=? AND pollqid=? AND userid=?",
-                         undef, $poll->journalid, $pollid, $qid, $remote->userid);
-            } else {
-                $dbh->do("DELETE FROM pollresult WHERE pollid=? AND pollqid=? AND userid=?",
-                         undef, $pollid, $qid, $remote->userid);
-            }
+            $poll->journal->do( "DELETE FROM pollresult2 WHERE journalid=? AND pollid=? AND pollqid=? AND userid=?",
+                                undef, $poll->journalid, $pollid, $qid, $remote->userid );
         }
     }
 
     ## finally, register the vote happened
-    if ($poll->is_clustered) {
-        $poll->journal->do("REPLACE INTO pollsubmission2 (journalid, pollid, userid, datesubmit) VALUES (?, ?, ?, NOW())",
-                           undef, $poll->journalid, $pollid, $remote->userid);
-    } else {
-        $dbh->do("REPLACE INTO pollsubmission (pollid, userid, datesubmit) VALUES (?, ?, NOW())",
-                 undef, $pollid, $remote->userid);
-    }
+    $poll->journal->do( "REPLACE INTO pollsubmission2 (journalid, pollid, userid, datesubmit) VALUES (?, ?, ?, NOW())",
+                        undef, $poll->journalid, $pollid, $remote->userid );
 
     # if vote results are not cached, there is no need to modify cache
     #$poll->_remove_from_memcache;
@@ -1498,98 +1380,12 @@ sub process_submission {
     return 1;
 }
 
-# take a user on dversion 7 and upgrade them to dversion 8 (clustered polls)
-sub make_polls_clustered {
-    my ($class, $u, $dbh, $dbhslo, $dbcm) = @_;
-
-    return 1 if $u->dversion >= 8;
-
-    return 0 unless ($dbh && $dbhslo && $dbcm);
-
-    # find polls this user owns
-    my $psth = $dbhslo->prepare("SELECT pollid, itemid, journalid, posterid, whovote, whoview, name, " .
-                             "status FROM poll WHERE journalid=?");
-    $psth->execute($u->userid);
-    die $psth->errstr if $psth->err;
-
-    while (my @prow = $psth->fetchrow_array) {
-        my $pollid = $prow[0];
-        # insert a copy into poll2
-        $dbcm->do("REPLACE INTO poll2 (pollid, ditemid, journalid, posterid, whovote, whoview, name, " .
-               "status) VALUES (?,?,?,?,?,?,?,?)", undef, @prow);
-        die $dbcm->errstr if $dbcm->err;
-
-        # map pollid -> userid
-        $dbh->do("REPLACE INTO pollowner (journalid, pollid) VALUES (?, ?)", undef,
-                 $u->userid, $pollid);
-        die $dbh->errstr if $dbh->err;
-
-        # get questions
-        my $qsth = $dbhslo->prepare("SELECT pollid, pollqid, sortorder, type, opts, qtext FROM " .
-                                 "pollquestion WHERE pollid=?");
-        $qsth->execute($pollid);
-        die $qsth->errstr if $qsth->err;
-
-        # copy questions to clustered table
-        while (my @qrow = $qsth->fetchrow_array) {
-            my $pollqid = $qrow[1];
-
-            # insert question into pollquestion2
-            $dbcm->do("REPLACE INTO pollquestion2 (journalid, pollid, pollqid, sortorder, type, opts, qtext) " .
-                   "VALUES (?, ?, ?, ?, ?, ?, ?)", undef, $u->userid, @qrow);
-            die $dbcm->errstr if $dbcm->err;
-
-            # get items
-            my $isth = $dbhslo->prepare("SELECT pollid, pollqid, pollitid, sortorder, item FROM pollitem " .
-                                     "WHERE pollid=? AND pollqid=?");
-            $isth->execute($pollid, $pollqid);
-            die $isth->errstr if $isth->err;
-
-            # copy items
-            while (my @irow = $isth->fetchrow_array) {
-                # copy item to pollitem2
-                $dbcm->do("REPLACE INTO pollitem2 (journalid, pollid, pollqid, pollitid, sortorder, item) VALUES " .
-                       "(?, ?, ?, ?, ?, ?)", undef, $u->userid, @irow);
-                die $dbcm->errstr if $dbcm->err;
-            }
-        }
-
-        # copy submissions
-        my $ssth = $dbhslo->prepare("SELECT userid, datesubmit FROM pollsubmission WHERE pollid=?");
-        $ssth->execute($pollid);
-        die $ssth->errstr if $ssth->err;
-
-        while (my @srow = $ssth->fetchrow_array) {
-            # copy to pollsubmission2
-            $dbcm->do("REPLACE INTO pollsubmission2 (pollid, journalid, userid, datesubmit) " .
-                   "VALUES (?, ?, ?, ?)", undef, $pollid, $u->userid, @srow);
-            die $dbcm->errstr if $dbcm->err;
-        }
-
-        # copy results
-        my $rsth = $dbhslo->prepare("SELECT pollid, pollqid, userid, value FROM pollresult WHERE pollid=?");
-        $rsth->execute($pollid);
-        die $rsth->errstr if $rsth->err;
-
-        while (my @rrow = $rsth->fetchrow_array) {
-            # copy to pollresult2
-            $dbcm->do("REPLACE INTO pollresult2 (journalid, pollid, pollqid, userid, value) " .
-                   "VALUES (?, ?, ?, ?, ?)", undef, $u->userid, @rrow);
-            die $dbcm->errstr if $dbcm->err;
-        }
-    }
-
-    return 1;
-}
-
 sub dump_poll {
     my $self = shift;
     my $fh = shift || \*STDOUT;
 
-    my @tables = ($self->is_clustered) ?
-        qw(poll2 pollquestion2 pollitem2 pollsubmission2 pollresult2) :
-        qw(poll  pollquestion  pollitem  pollsubmission  pollresult );
-    my $db = ($self->is_clustered) ? $self->journal : LJ::get_db_reader();
+    my @tables = qw(poll2 pollquestion2 pollitem2 pollsubmission2 pollresult2);
+    my $db = $self->journal;
     my $id = $self->pollid;
 
     print $fh "<poll id='$id'>\n";
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/LJ/Poll/Question.pm
--- a/cgi-bin/LJ/Poll/Question.pm	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/LJ/Poll/Question.pm	Sat Sep 05 14:35:14 2009 +0000
@@ -46,18 +46,10 @@ sub _load {
     croak "_load called on a LJ::Poll::Question object with no pollqid"
         unless $self->pollqid;
 
-    my $sth;
+    my $sth = $self->poll->journal->prepare( 'SELECT * FROM pollquestion2 WHERE pollid=? AND pollqid=? and journalid=?' );
+    $sth->execute( $self->pollid, $self->pollqid, $self->poll->journalid );
 
-    if ($self->is_clustered) {
-        $sth = $self->poll->journal->prepare('SELECT * FROM pollquestion2 WHERE pollid=? AND pollqid=? and journalid=?');
-        $sth->execute($self->pollid, $self->pollqid, $self->poll->journalid);
-    } else {
-        my $dbr = LJ::get_db_reader();
-        my $sth = $dbr->prepare('SELECT * FROM pollquestion WHERE pollid=? AND pollqid=?');
-        $sth->execute($self->pollid, $self->pollqid);
-    }
-
-    $self->absorb_row($sth->fetchrow_hashref);
+    $self->absorb_row( $sth->fetchrow_hashref );
 }
 
 # returns the question rendered for previewing
@@ -132,18 +124,9 @@ sub items {
 
     return @{$self->{items}} if $self->{items};
 
-    my $sth;
-
-    if ($self->is_clustered) {
-        $sth = $self->poll->journal->prepare('SELECT pollid, pollqid, pollitid, sortorder, item ' .
-                                             'FROM pollitem2 WHERE pollid=? AND pollqid=? AND journalid=?');
-        $sth->execute($self->pollid, $self->pollqid, $self->poll->journalid);
-    } else {
-        my $dbr = LJ::get_db_reader();
-        $sth = $dbr->prepare('SELECT pollid, pollqid, pollitid, sortorder, item ' .
-                                             'FROM pollitem WHERE pollid=? AND pollqid=?');
-        $sth->execute($self->pollid, $self->pollqid);
-    }
+    my $sth = $self->poll->journal->prepare( 'SELECT pollid, pollqid, pollitid, sortorder, item ' .
+                                             'FROM pollitem2 WHERE pollid=? AND pollqid=? AND journalid=?' );
+    $sth->execute( $self->pollid, $self->pollqid, $self->poll->journalid );
 
     die $sth->errstr if $sth->err;
 
@@ -166,10 +149,6 @@ sub poll {
 sub poll {
     my $self = shift;
     return $self->{poll};
-}
-sub is_clustered {
-    my $self = shift;
-    return $self->poll->is_clustered;
 }
 sub pollid {
     my $self = shift;
@@ -210,32 +189,15 @@ sub answers_pages {
 
     my $pages = 0;
 
-    my $sth;
-
-    if ($self->is_clustered) {
-        # Get results count
-        $sth = $self->poll->journal->prepare(
-            "SELECT COUNT(*) as count".
-            " FROM pollresult2".
-            " WHERE pollid=? AND pollqid=? AND journalid=?");
-        $sth->execute($self->pollid, $self->pollqid, $jid);
-        die $sth->errstr if $sth->err;
-        $_ = $sth->fetchrow_hashref;
-        my $count = $_->{count};
-        $pages = 1+int(($count-1)/$pagesize);
-    } else {
-        my $dbr = LJ::get_db_reader();
-        # Get count
-        $sth = $self->poll->journal->prepare(
-            "SELECT COUNT(*) as count".
-            " FROM pollresult".
-            " WHERE pollid=? AND pollqid=?");
-        $sth->execute($self->pollid, $self->pollqid);
-        die $sth->errstr if $sth->err;
-        $_ = $sth->fetchrow_hashref;
-        my $count = $_->{count};
-        $pages = 1+int(($count-1)/$pagesize);
-    }
+    # Get results count
+    my $sth = $self->poll->journal->prepare(
+        "SELECT COUNT(*) as count FROM pollresult2".
+        " WHERE pollid=? AND pollqid=? AND journalid=?" );
+    $sth->execute( $self->pollid, $self->pollqid, $jid );
+    die $sth->errstr if $sth->err;
+    $_ = $sth->fetchrow_hashref;
+    my $count = $_->{count};
+    $pages = 1 + int( ($count - 1) / $pagesize );
     die $sth->errstr if $sth->err;
 
     return $pages;
@@ -251,36 +213,21 @@ sub answers_as_html {
     my $pages = shift || $self->answers_pages($jid, $pagesize);
 
     my $ret = '';;
-    my $sth;
 
-    if ($self->is_clustered) {
-        my $LIMIT = $pagesize * ($page - 1) . "," . $pagesize;
+    my $LIMIT = $pagesize * ($page - 1) . "," . $pagesize;
 
-        # Get data
-        $sth = $self->poll->journal->prepare(
+    # Get data
+    my $sth = $self->poll->journal->prepare(
             "SELECT pr.value, ps.datesubmit, pr.userid " .
             "FROM pollresult2 pr, pollsubmission2 ps " .
             "WHERE pr.pollid=? AND pollqid=? " .
             "AND ps.pollid=pr.pollid AND ps.userid=pr.userid " .
             "AND ps.journalid=? ".
-            "LIMIT $LIMIT");
-        $sth->execute($self->pollid, $self->pollqid, $jid);
-    } else {
-        my $dbr = LJ::get_db_reader();
-        my $LIMIT = $pagesize  * ($page - 1) . "," . $pagesize;
-
-        # Get data
-        $sth = $dbr->prepare(
-            "SELECT pr.value, ps.datesubmit, pr.userid ".
-            "FROM pollresult pr, pollsubmission ps " .
-            "WHERE pr.pollid=? AND pollqid=? " .
-            "AND ps.pollid=pr.pollid AND ps.userid=pr.userid ".
-            "LIMIT $LIMIT");
-        $sth->execute($self->pollid, $self->pollqid);
-    }
+            "LIMIT $LIMIT" );
+    $sth->execute( $self->pollid, $self->pollqid, $jid );
     die $sth->errstr if $sth->err;
 
-    my ($pollid, $pollqid) = ($self->pollid, $self->pollqid);
+    my ( $pollid, $pollqid ) = ( $self->pollid, $self->pollqid );
 
     my @res;
     push @res, $_ while $_ = $sth->fetchrow_hashref;
@@ -335,17 +282,9 @@ sub answers {
     my $self = shift;
 
     my $ret = '';
-    my $sth;
-
-    if ($self->is_clustered) {
-        $sth = $self->poll->journal->prepare("SELECT userid, pollqid, value FROM pollresult2 " .
-                                             "WHERE pollid=? AND pollqid=?");
-    } else {
-        my $dbr = LJ::get_db_reader();
-        $sth = $dbr->prepare("SELECT userid, pollqid, value FROM pollresult " .
-                             "WHERE pollid=? AND pollqid=?");
-    }
-    $sth->execute($self->pollid, $self->pollqid);
+    my $sth = $self->poll->journal->prepare( "SELECT userid, pollqid, value FROM pollresult2 " .
+                                             "WHERE pollid=? AND pollqid=?" );
+    $sth->execute( $self->pollid, $self->pollqid );
     die $sth->errstr if $sth->err;
 
     my @res;
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/LJ/User.pm	Sat Sep 05 14:35:14 2009 +0000
@@ -4648,14 +4648,8 @@ sub activate_userpics {
     my $dbcr = LJ::get_cluster_def_reader($u);
 
     # select all userpics and build active / inactive lists
-    my $sth;
-    if ( $u->dversion > 6 ) {
-        return undef unless $dbcr;
-        $sth = $dbcr->prepare("SELECT picid, state FROM userpic2 WHERE userid=?");
-    } else {
-        return undef unless $dbh;
-        $sth = $dbh->prepare("SELECT picid, state FROM userpic WHERE userid=?");
-    }
+    return undef unless $dbcr;
+    my $sth = $dbcr->prepare( "SELECT picid, state FROM userpic2 WHERE userid=?" );
     $sth->execute($userid);
     while (my ($picid, $state) = $sth->fetchrow_array) {
         next if $state eq 'X'; # expunged, means userpic has been removed from site by admins
@@ -4693,16 +4687,9 @@ sub activate_userpics {
         # map pickws to picids for freq hash below
         my %count_picid = ();
         if ($keywords_in) {
-            my $sth;
-            if ( $u->dversion > 6 ) {
-                $sth = $dbcr->prepare("SELECT k.keyword, m.picid FROM userkeywords k, userpicmap2 m ".
+            my $sth = $dbcr->prepare( "SELECT k.keyword, m.picid FROM userkeywords k, userpicmap2 m ".
                                       "WHERE k.keyword IN ($keywords_in) AND k.kwid=m.kwid AND k.userid=m.userid " .
-                                      "AND k.userid=?");
-            } else {
-                $sth = $dbh->prepare("SELECT k.keyword, m.picid FROM keywords k, userpicmap m " .
-                                     "WHERE k.keyword IN ($keywords_in) AND k.kwid=m.kwid " .
-                                     "AND m.userid=?");
-            }
+                                      "AND k.userid=?" );
             $sth->execute($userid);
             while (my ($keyword, $picid) = $sth->fetchrow_array) {
                 # keyword => picid
@@ -4716,13 +4703,8 @@ sub activate_userpics {
 
         @ban = splice(@ban, 0, $to_ban) if @ban > $to_ban;
         my $ban_in = join(",", map { $dbh->quote($_) } @ban);
-        if ( $u->dversion > 6 ) {
-            $u->do("UPDATE userpic2 SET state='I' WHERE userid=? AND picid IN ($ban_in)",
-                   undef, $userid) if $ban_in;
-        } else {
-            $dbh->do("UPDATE userpic SET state='I' WHERE userid=? AND picid IN ($ban_in)",
-                     undef, $userid) if $ban_in;
-        }
+        $u->do( "UPDATE userpic2 SET state='I' WHERE userid=? AND picid IN ($ban_in)",
+                undef, $userid ) if $ban_in;
     }
 
     # activate previously inactivated userpics
@@ -4736,14 +4718,9 @@ sub activate_userpics {
         my @activate_picids = splice(@inactive, -$to_activate);
 
         my $activate_in = join(",", map { $dbh->quote($_) } @activate_picids);
-        if ($activate_in) {
-            if ( $u->dversion > 6 ) {
-                $u->do("UPDATE userpic2 SET state='N' WHERE userid=? AND picid IN ($activate_in)",
-                       undef, $userid);
-            } else {
-                $dbh->do("UPDATE userpic SET state='N' WHERE userid=? AND picid IN ($activate_in)",
-                         undef, $userid);
-            }
+        if ( $activate_in ) {
+            $u->do( "UPDATE userpic2 SET state='N' WHERE userid=? AND picid IN ($activate_in)",
+                    undef, $userid );
         }
     }
 
@@ -4840,31 +4817,6 @@ sub remove_friend {
     confess 'LJ::User->remove_friend has been deprecated.';
 }
 
-
-# take a user on dversion 7 and upgrade them to dversion 8 (clustered polls)
-# DW doesn't support anything earlier than dversion 8, so this can
-# probably go away at some point.
-
-# returns if this user's polls are clustered
-# DW doesn't support anything earlier than dversion 8, so this can
-# probably go away at some point.
-sub polls_clustered {
-    my $u = shift;
-    return $u->dversion >= 8;
-}
-
-
-sub upgrade_to_dversion_8 {
-    my ( $u, $dbh, $dbhslo, $dbcm ) = @_;
-
-    # If user has been purged, go ahead and update version
-    # Otherwise move their polls
-    my $ok = $u->is_expunged ? 1 : LJ::Poll->make_polls_clustered($u, $dbh, $dbhslo, $dbcm);
-
-    LJ::update_user($u, { 'dversion' => 8 }) if $ok;
-
-    return $ok;
-}
 
 # FIXME: Needs updating for WTF
 sub opt_showmutualfriends {
@@ -8153,15 +8105,10 @@ sub userpic_count {
 sub userpic_count {
     my $u = shift or return undef;
 
-    if ( $u->dversion > 6 ) {
-        my $dbcr = LJ::get_cluster_def_reader($u) or return undef;
-        return $dbcr->selectrow_array("SELECT COUNT(*) FROM userpic2 " .
-                                      "WHERE userid=? AND state <> 'X'", undef, $u->userid);
-    }
-
-    my $dbh = LJ::get_db_writer() or return undef;
-    return $dbh->selectrow_array("SELECT COUNT(*) FROM userpic " .
-                                 "WHERE userid=? AND state <> 'X'", undef, $u->userid);
+    my $dbcr = LJ::get_cluster_def_reader( $u ) or return undef;
+    return $dbcr->selectrow_array( "SELECT COUNT(*) FROM userpic2 " .
+                                   "WHERE userid=? AND state <> 'X'",
+                                   undef, $u->userid );
 }
 
 
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/LJ/Userpic.pm
--- a/cgi-bin/LJ/Userpic.pm	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/LJ/Userpic.pm	Sat Sep 05 14:35:14 2009 +0000
@@ -97,15 +97,8 @@ sub new_from_md5 {
     my ($class, $u, $md5sum) = @_;
     die unless $u && length($md5sum) == 22;
 
-    my $sth;
-    if (LJ::Userpic->userpics_partitioned($u)) {
-        $sth = $u->prepare("SELECT * FROM userpic2 WHERE userid=? " .
-                           "AND md5base64=?");
-    } else {
-        my $dbr = LJ::get_db_reader();
-        $sth = $dbr->prepare("SELECT * FROM userpic WHERE userid=? " .
-                             "AND md5base64=?");
-    }
+    my $sth = $u->prepare( "SELECT * FROM userpic2 WHERE userid=? " .
+                           "AND md5base64=?" );
     $sth->execute($u->{'userid'}, $md5sum);
     my $row = $sth->fetchrow_hashref
         or return undef;
@@ -467,11 +460,6 @@ sub imagedata {
         return $$data;
     }
 
-    my %MimeTypeMap = (
-                       'image/gif' => 'gif',
-                       'image/jpeg' => 'jpg',
-                       'image/png' => 'png',
-                       );
     my %MimeTypeMapd6 = (
                          'G' => 'gif',
                          'J' => 'jpg',
@@ -480,7 +468,7 @@ sub imagedata {
 
     my $data;
     if ($LJ::USERPIC_BLOBSERVER) {
-        my $fmt = ($u->{'dversion'} > 6) ? $MimeTypeMapd6{ $pic->{fmt} } : $MimeTypeMap{ $pic->{contenttype} };
+        my $fmt = $MimeTypeMapd6{ $pic->{fmt} };
         $data = LJ::Blob::get($u, "userpic", $fmt, $self->{picid});
         return $data if $data;
     }
@@ -493,23 +481,6 @@ sub imagedata {
                                   $self->{picid});
     return $data ? $data : undef;
 }
-
-# does the user's dataversion support userpic comments?
-sub supports_comments {
-    my $self = shift;
-
-    my $u = $self->owner;
-    return $u->{dversion} > 6;
-}
-
-# class method
-# does this user's dataversion support userpic comments?
-sub userpics_partitioned {
-    my ($class, $u) = @_;
-    Carp::croak("Not a valid \$u object") unless LJ::isu($u);
-    return $u->{dversion} > 6;
-}
-*user_supports_comments = \&userpics_partitioned;
 
 # TODO: add in lazy peer loading here
 sub load_row {
@@ -530,18 +501,10 @@ sub load_row {
     # If you get past this conditional something is wrong
     # load_user_userpics  always returns a value
 
-    my $row;
-    if (LJ::Userpic->userpics_partitioned($u)) {
-        $row = $u->selectrow_hashref("SELECT userid, picid, width, height, state, fmt, comment, description, location, url, " .
+    my $row = $u->selectrow_hashref( "SELECT userid, picid, width, height, state, fmt, comment, description, location, url, " .
                                      "UNIX_TIMESTAMP(picdate) AS 'pictime', flags, md5base64 " .
                                      "FROM userpic2 WHERE userid=? AND picid=?", undef,
-                                     $u->{userid}, $self->{picid});
-    } else {
-        my $dbr = LJ::get_db_reader();
-        $row = $dbr->selectrow_hashref("SELECT userid, picid, width, height, state, contenttype " .
-                                       "FROM userpic WHERE userid=? AND picid=?", undef,
-                                       $u->{userid}, $self->{picid});
-    }
+                                     $u->userid, $self->{picid} );
     $self->absorb_row($row) if $row;
 }
 
@@ -559,9 +522,6 @@ sub get_cache {
     if ($u->{_userpicids}) {
         return [ map { LJ::Userpic->instance($u, $_) } @{$u->{_userpicids}} ];
     }
-
-    # no memcaching of userpic2 rows unless partitioned
-    return undef unless LJ::Userpic->userpics_partitioned($u);
 
     my $memkey = $class->memkey($u);
     my $memval = LJ::MemCache::get($memkey);
@@ -593,12 +553,9 @@ sub set_cache {
     my $u = shift;
     my $rows = shift;
 
-    # no memcaching of userpic2 rows unless partitioned
-    if (LJ::Userpic->userpics_partitioned($u)) {
-        my $memkey = $class->memkey($u);
-        my @vals = map { LJ::MemCache::hash_to_array('userpic2', $_) } @$rows;
-        LJ::MemCache::set($memkey, \@vals, 60*30);
-    }
+    my $memkey = $class->memkey( $u );
+    my @vals = map { LJ::MemCache::hash_to_array( 'userpic2', $_ ) } @$rows;
+    LJ::MemCache::set( $memkey, \@vals, 60*30 );
 
     # set cache of picids on $u
     $u->{_userpicids} = [ map { $_->{picid} } @$rows ];
@@ -615,17 +572,10 @@ sub load_user_userpics {
     return @$cache if $cache;
 
     # select all of their userpics and iterate through them
-    my $sth;
-    if (LJ::Userpic->userpics_partitioned($u)) {
-        $sth = $u->prepare("SELECT userid, picid, width, height, state, fmt, comment, description, location, " .
+    my $sth = $u->prepare( "SELECT userid, picid, width, height, state, fmt, comment, description, location, " .
                            "UNIX_TIMESTAMP(picdate) AS 'pictime', flags, md5base64 " .
-                           "FROM userpic2 WHERE userid=?");
-    } else {
-        my $dbh = LJ::get_db_writer();
-        $sth = $dbh->prepare("SELECT userid, picid, width, height, state, contenttype " .
-                             "FROM userpic WHERE userid=?");
-    }
-    $sth->execute($u->{'userid'});
+                           "FROM userpic2 WHERE userid=?" );
+    $sth->execute( $u->userid );
     die "Error loading userpics: clusterid=$u->{clusterid}, errstr=" . $sth->errstr if $sth->err;
 
     while (my $rec = $sth->fetchrow_hashref) {
@@ -690,9 +640,9 @@ sub create {
     my $base64 = Digest::MD5::md5_base64($$dataref);
 
     my $target;
-    if ($u->{dversion} > 6 && $LJ::USERPIC_MOGILEFS) {
+    if ( $LJ::USERPIC_MOGILEFS ) {
         $target = 'mogile';
-    } elsif ($LJ::USERPIC_BLOBSERVER) {
+    } elsif ( $LJ::USERPIC_BLOBSERVER ) {
         $target = 'blob';
     }
 
@@ -706,49 +656,26 @@ sub create {
     # start making a new onew
     my $picid = LJ::alloc_global_counter('P');
 
-    my $contenttype;
-    if (LJ::Userpic->userpics_partitioned($u)) {
-        $contenttype = {
+    my $contenttype = {
             'GIF' => 'G',
             'PNG' => 'P',
             'JPG' => 'J',
         }->{$filetype};
-    } else {
-        $contenttype = {
-            'GIF' => 'image/gif',
-            'PNG' => 'image/png',
-            'JPG' => 'image/jpeg',
-        }->{$filetype};
-    }
 
     @errors = (); # TEMP: FIXME: remove... using exceptions
 
     my $dberr = 0;
-    if ($u->{'dversion'} > 6) {
-        $u->do("INSERT INTO userpic2 (picid, userid, fmt, width, height, " .
-               "picdate, md5base64, location) VALUES (?, ?, ?, ?, ?, NOW(), ?, ?)",
-               undef, $picid, $u->{'userid'}, $contenttype, $w, $h, $base64, $target);
-        if ($u->err) {
-            push @errors, $err->($u->errstr);
-            $dberr = 1;
-        }
-    } else {
-        $dbh->do("INSERT INTO userpic (picid, userid, contenttype, width, height, " .
-                 "picdate, md5base64) VALUES (?, ?, ?, ?, ?, NOW(), ?)",
-                 undef, $picid, $u->{'userid'}, $contenttype, $w, $h, $base64);
-        if ($dbh->err) {
-            push @errors, $err->($dbh->errstr);
-            $dberr = 1;
-        }
+    $u->do( "INSERT INTO userpic2 (picid, userid, fmt, width, height, " .
+            "picdate, md5base64, location) VALUES (?, ?, ?, ?, ?, NOW(), ?, ?)",
+            undef, $picid, $u->userid, $contenttype, $w, $h, $base64, $target );
+    if ( $u->err ) {
+        push @errors, $err->( $u->errstr );
+        $dberr = 1;
     }
 
     my $clean_err = sub {
-        if ($u->{'dversion'} > 6) {
-            $u->do("DELETE FROM userpic2 WHERE userid=? AND picid=?",
-                   undef, $u->{'userid'}, $picid) if $picid;
-        } else {
-            $dbh->do("DELETE FROM userpic WHERE picid=?", undef, $picid) if $picid;
-        }
+        $u->do( "DELETE FROM userpic2 WHERE userid=? AND picid=?",
+                undef, $u->userid, $picid ) if $picid;
         return $err->(@_);
     };
 
@@ -860,21 +787,12 @@ sub delete {
     $fail->() if $@;
 
     # userpic keywords
-    if (LJ::Userpic->userpics_partitioned($u)) {
-        eval {
-            $u->do("DELETE FROM userpicmap2 WHERE userid=? " .
-                   "AND picid=?", undef, $u->{userid}, $picid) or die;
-            $u->do("DELETE FROM userpic2 WHERE picid=? AND userid=?",
-                   undef, $picid, $u->{'userid'}) or die;
-            };
-    } else {
-        eval {
-            my $dbh = LJ::get_db_writer();
-            $dbh->do("DELETE FROM userpicmap WHERE userid=? " .
-                 "AND picid=?", undef, $u->{userid}, $picid) or die;
-            $dbh->do("DELETE FROM userpic WHERE picid=?", undef, $picid) or die;
+    eval {
+        $u->do( "DELETE FROM userpicmap2 WHERE userid=? " .
+                "AND picid=?", undef, $u->userid, $picid ) or die;
+        $u->do( "DELETE FROM userpic2 WHERE picid=? AND userid=?",
+                undef, $picid, $u->userid ) or die;
         };
-    }
     $fail->() if $@;
 
     $u->log_event('delete_userpic', { picid => $picid });
@@ -903,7 +821,6 @@ sub set_comment {
     local $LJ::THROW_ERRORS = 1;
 
     my $u = $self->owner;
-    return 0 unless LJ::Userpic->user_supports_comments($u);
     $comment = LJ::text_trim($comment, LJ::BMAX_UPIC_COMMENT(), LJ::CMAX_UPIC_COMMENT());
     $u->do("UPDATE userpic2 SET comment=? WHERE userid=? AND picid=?",
                   undef, $comment, $u->{'userid'}, $self->id)
@@ -946,13 +863,8 @@ sub set_keywords {
     my $sth;
     my $dbh;
 
-    if (LJ::Userpic->userpics_partitioned($u)) {
-        $sth = $u->prepare("SELECT kwid FROM userpicmap2 WHERE userid=? AND picid=?");
-    } else {
-        $dbh = LJ::get_db_writer();
-        $sth = $dbh->prepare("SELECT kwid FROM userpicmap WHERE userid=? AND picid=?");
-    }
-    $sth->execute($u->{'userid'}, $self->id);
+    $sth = $u->prepare( "SELECT kwid FROM userpicmap2 WHERE userid=? AND picid=?" );
+    $sth->execute( $u->userid, $self->id );
 
     my %exist_kwids;
     while (my ($kwid) = $sth->fetchrow_array) {
@@ -964,7 +876,7 @@ sub set_keywords {
     my $picid = $self->{picid};
 
     foreach my $kw (@keywords) {
-        my $kwid = (LJ::Userpic->userpics_partitioned($u)) ? LJ::get_keyword_id($u, $kw) : LJ::get_keyword_id($kw);
+        my $kwid = LJ::get_keyword_id( $u, $kw );
         next unless $kwid; # TODO: fire some warning that keyword was bogus
 
         if (++$c > $LJ::MAX_USERPIC_KEYWORDS) {
@@ -988,13 +900,8 @@ sub set_keywords {
     if (scalar @data) {
         my $bind = join(',', @bind);
 
-        if (LJ::Userpic->userpics_partitioned($u)) {
-            $u->do("REPLACE INTO userpicmap2 (userid, kwid, picid) VALUES $bind",
-                          undef, @data);
-        } else {
-            $dbh->do("INSERT INTO userpicmap (userid, kwid, picid) VALUES $bind",
-                            undef, @data);
-        }
+        $u->do( "REPLACE INTO userpicmap2 (userid, kwid, picid) VALUES $bind",
+                undef, @data );
     }
 
     # Let the user know about any we didn't save
@@ -1012,7 +919,6 @@ sub set_fullurl {
 sub set_fullurl {
     my ($self, $url) = @_;
     my $u = $self->owner;
-    return 0 unless LJ::Userpic->userpics_partitioned($u);
     $u->do("UPDATE userpic2 SET url=? WHERE userid=? AND picid=?",
            undef, $url, $u->{'userid'}, $self->id);
     $self->{url} = $url;
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/ljlib.pl	Sat Sep 05 14:35:14 2009 +0000
@@ -1542,8 +1542,7 @@ sub get_keyword_id
 
     # get the keyword and insert it if necessary
     my $kwid;
-    if ($u && $u->{dversion} > 5) {
-        # new style userkeywords -- but only if the user has the right dversion
+    if ( $u ) {
         $kwid = $u->selectrow_array('SELECT kwid FROM userkeywords WHERE userid = ? AND keyword = ?',
                                     undef, $u->{userid}, $kw) + 0;
         if ($autovivify && ! $kwid) {
@@ -1564,18 +1563,6 @@ sub get_keyword_id
 
             # nuke cache
             LJ::MemCache::delete([ $u->{userid}, "kws:$u->{userid}" ]);
-        }
-    } else {
-        # old style global
-        my $dbh = LJ::get_db_writer();
-        my $qkw = $dbh->quote($kw);
-
-        # Making this a $dbr could cause problems due to the insertion of
-        # data based on the results of this query. Leave as a $dbh.
-        $kwid = $dbh->selectrow_array("SELECT kwid FROM keywords WHERE keyword=$qkw");
-        if ($autovivify && ! $kwid) {
-            $dbh->do("INSERT INTO keywords (kwid, keyword) VALUES (NULL, $qkw)");
-            $kwid = $dbh->{'mysql_insertid'};
         }
     }
     return $kwid;
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/ljmemories.pl
--- a/cgi-bin/ljmemories.pl	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/ljmemories.pl	Sat Sep 05 14:35:14 2009 +0000
@@ -21,17 +21,11 @@ sub count {
     return $count if $count;
 
     # now count
-    if ($u->{dversion} > 5) {
-        my $dbcr = LJ::get_cluster_def_reader($u);
-        $count = $dbcr->selectrow_array('SELECT COUNT(*) FROM memorable2 WHERE userid = ?',
-                                        undef, $u->{userid});
-        return undef if $dbcr->err;
-    } else {
-        my $dbh = LJ::get_db_writer();
-        $count = $dbh->selectrow_array('SELECT COUNT(*) FROM memorable WHERE userid = ?',
-                                       undef, $u->{userid});
-        return undef if $dbh->err;
-    }
+    my $dbcr = LJ::get_cluster_def_reader( $u );
+    $count = $dbcr->selectrow_array( 'SELECT COUNT(*) FROM memorable2 WHERE userid = ?',
+                                        undef, $u->{userid} );
+    return undef if $dbcr->err;
+
     $count += 0;
 
     # now put in memcache and return it
@@ -56,8 +50,8 @@ sub create {
     return undef unless $u && %{$opts || {}};
 
     # make sure we got enough options
-    my ($userid, $journalid, $ditemid, $des, $security) =
-        ($u->{userid}, map { $opts->{$_} } qw(journalid ditemid des security));
+    my ( $userid, $journalid, $ditemid, $des, $security ) =
+        ( $u->userid, map { $opts->{$_} } qw(journalid ditemid des security) );
     $userid += 0;
     $journalid += 0;
     $ditemid += 0;
@@ -68,44 +62,29 @@ sub create {
     return undef unless $security =~ /^(?:public|friends|private)$/;
 
     # we have valid data, now let's insert it
-    if ($u->{dversion} > 5) {
-        return undef unless $u->writer;
+    return undef unless $u->writer;
 
-        # allocate memory id to use
-        my $memid = LJ::alloc_user_counter($u, 'R');
-        return undef unless $memid;
+    # allocate memory id to use
+    my $memid = LJ::alloc_user_counter( $u, 'R' );
+    return undef unless $memid;
 
-        # insert main memory
-        $u->do("INSERT INTO memorable2 (userid, memid, journalid, ditemid, des, security) " .
-               "VALUES (?, ?, ?, ?, ?, ?)", undef, $userid, $memid, $journalid, $ditemid, $des, $security);
+    # insert main memory
+    $u->do( "INSERT INTO memorable2 (userid, memid, journalid, ditemid, des, security) " .
+            "VALUES (?, ?, ?, ?, ?, ?)", undef, $userid, $memid, $journalid, $ditemid, $des, $security );
         return undef if $u->err;
 
-        # insert keywords
-        my $val = join ',', map { "($u->{userid}, $memid, $_)" } @$kwids;
-        $u->do("REPLACE INTO memkeyword2 (userid, memid, kwid) VALUES $val");
+    # insert keywords
+    my $val = join ',', map { "($userid, $memid, $_)" } @$kwids;
+    $u->do( "REPLACE INTO memkeyword2 (userid, memid, kwid) VALUES $val" );
 
-    } else {
-        my $dbh = LJ::get_db_writer();
-        return undef unless $dbh;
-
-        # insert main memory
-        $dbh->do("INSERT INTO memorable (userid, journalid, jitemid, des, security) " .
-                 "VALUES (?, ?, ?, ?, ?)", undef, $userid, $journalid, $ditemid, $des, $security);
-        return undef if $dbh->err;
-
-        # insert keywords
-        my $memid = $dbh->{mysql_insertid}+0;
-        my $val = join ',', map { "($memid, $_)" } @$kwids;
-        $dbh->do("REPLACE INTO memkeyword (memid, kwid) VALUES $val");
-    }
 
     # Delete the appropriate memcache entries
-    LJ::MemCache::delete([$u->{userid}, "memct:$u->{userid}"]);
-    my $filter = $journalid == $u->{userid} ? 'own' : 'other';
+    LJ::MemCache::delete( [$userid, "memct:$userid"] );
+    my $filter = $journalid == $userid ? 'own' : 'other';
     my $filter_char   = _map_filter_to_char($filter);
     my $security_char = _map_security_to_char($security);
-    my $memcache_key = "memkwcnt:$u->{userid}:$filter_char:$security_char";
-    LJ::MemCache::delete([$u->{userid}, $memcache_key]);
+    my $memcache_key = "memkwcnt:$userid:$filter_char:$security_char";
+    LJ::MemCache::delete( [$userid, $memcache_key] );
 
     return 1;
 }
@@ -120,32 +99,22 @@ sub create {
 # returns: 1 on success; undef on error.
 # </LJFUNC>
 sub delete_by_id {
-    my ($u, $memids) = @_;
-    $u = LJ::want_user($u);
+    my ( $u, $memids ) = @_;
+    $u = LJ::want_user( $u );
     $memids = [ $memids ] if $memids && !ref $memids; # so they can just pass a single thing...
     return undef unless $u && @{$memids || []};
 
     # setup
-    my ($db, $table) = $u->{dversion} > 5 ?
-                       ($u, '2') :
-                       (LJ::get_db_writer(), '');
+    my ( $db, $table ) = ( $u, '2' );
 
-    # if dversion 5, verify the ids
-    my $in = join ',', map { $_+0 } @$memids;
-    if ($u->{dversion} == 5) {
-        $memids = $db->selectcol_arrayref("SELECT memid FROM memorable WHERE userid = ? AND memid IN ($in)",
-                                          undef, $u->{userid});
-        return undef if $db->err;
-        return 1 unless @{$memids || []}; # if we got nothing, pretend success
-        $in = join ',', map { $_+0 } @$memids;
-    }
+    my $in = join ',', map { $_ + 0 } @$memids;
 
     # delete actual memory
     $db->do("DELETE FROM memorable$table WHERE userid = ? AND memid IN ($in)", undef, $u->{userid});
     return undef if $db->err;
 
     # delete keyword associations
-    my $euser = $u->{dversion} > 5 ? "userid = $u->{userid} AND" : '';
+    my $euser = "userid = $u->{userid} AND";
     $db->do("DELETE FROM memkeyword$table WHERE $euser memid IN ($in)");
 
     # delete cache of count and keyword counts
@@ -198,17 +167,10 @@ sub get_keyword_counts {
 
     if (@all_memids) {
         my $in = join ',', @all_memids;
-        if ($u->{dversion} > 5) {
-            my $dbcr = LJ::get_cluster_reader($u);
-            my $sql = "SELECT kwid, memid FROM memkeyword2 WHERE userid = $userid AND memid IN ($in)";
-            $mem_kw_rows = $dbcr->selectall_arrayref($sql);
-            return undef if $dbcr->err;
-        } else {
-            my $dbr = LJ::get_db_reader();
-            my $sql = "SELECT kwid, memid FROM memkeyword WHERE kwid IN ($in)";
-            $mem_kw_rows = $dbr->selectall_arrayref($sql);
-            return undef if $dbr->err;
-        }
+        my $dbcr = LJ::get_cluster_reader( $u );
+        my $sql = "SELECT kwid, memid FROM memkeyword2 WHERE userid = $userid AND memid IN ($in)";
+        $mem_kw_rows = $dbcr->selectall_arrayref( $sql );
+        return undef if $dbcr->err;
     }
 
     # Filter and Sum
@@ -356,25 +318,18 @@ sub add_hash {
 # returns: Arrayref of keywordids; undef on error.
 # </LJFUNC>
 sub get_keywordids {
-    my ($u, $memid) = @_;
-    $u = LJ::want_user($u);
+    my ( $u, $memid ) = @_;
+    $u = LJ::want_user( $u );
     $memid += 0;
     return undef unless $u && $memid;
 
     # definitive reader/master because this function is usually called when
     # someone is on an edit page.
-    my $kwids;
-    if ($u->{dversion} > 5) {
-        my $dbcr = LJ::get_cluster_def_reader($u);
-        $kwids = $dbcr->selectcol_arrayref('SELECT kwid FROM memkeyword2 WHERE userid = ? AND memid = ?',
-                                           undef, $u->{userid}, $memid);
-        return undef if $dbcr->err;
+    my $dbcr = LJ::get_cluster_def_reader( $u );
+    my $kwids = $dbcr->selectcol_arrayref( 'SELECT kwid FROM memkeyword2 WHERE userid = ? AND memid = ?',
+                                           undef, $u->userid, $memid );
+    return undef if $dbcr->err;
 
-    } else {
-        my $dbh = LJ::get_db_writer();
-        $kwids = $dbh->selectcol_arrayref('SELECT kwid FROM memkeyword WHERE memid = ?', undef, $memid);
-        return undef if $dbh->err;
-    }
 
     # all good, return
     return $kwids;
@@ -398,9 +353,7 @@ sub get_keywordids {
 #     return unless $u && $memid && %{$upd || {}};
 # 
 #     # get database handle
-#     my ($db, $table) = $u->{dversion} > 5 ?
-#                        ($u, '2') :
-#                        (LJ::get_db_writer(), '');
+#     my ($db, $table) = ($u, '2');
 #     return undef unless $db;
 # 
 #     # construct update lines... only valid things we can update are des and security
@@ -478,31 +431,23 @@ sub _memory_getter {
         $selwhere = "AND memid IN ($in)";
     } elsif ($opts->{byditemid} && $opts->{journalid}) {
         # or, they want to see if a memory exists for a particular item
-        my $selitemid = $u->{dversion} > 5 ? "ditemid" : "jitemid";
+        my $selitemid = "ditemid";
         $opts->{byditemid} += 0;
         $opts->{journalid} += 0;
         $selwhere = "AND journalid = $opts->{journalid} AND $selitemid = $opts->{byditemid}";
     } elsif ($opts->{byditemid}) {
         # get memory, OLD STYLE so journalid is 0
-        my $selitemid = $u->{dversion} > 5 ? "ditemid" : "jitemid";
+        my $selitemid = "ditemid";
         $opts->{byditemid} += 0;
         $selwhere = "AND journalid = 0 AND $selitemid = $opts->{byditemid}";
     }
 
     # load up memories into hashref
-    my (%memories, $sth);
-    if ($u->{dversion} > 5) {
-        # new clustered memories
-        my $dbcr = LJ::get_cluster_reader($u);
-        my $sql = "SELECT memid, userid, journalid, ditemid, $des security "
-           . "FROM memorable2 WHERE userid = ? $selwhere $secwhere $extrawhere";
-        $sth = $dbcr->prepare($sql);
-    } else {
-        # old global memories
-        my $dbr = LJ::get_db_reader();
-        $sth = $dbr->prepare("SELECT memid, userid, journalid, jitemid, $des security " .
-                             "FROM memorable WHERE userid = ? $selwhere $secwhere $extrawhere");
-    }
+    my ( %memories, $sth );
+    my $dbcr = LJ::get_cluster_reader( $u );
+    my $sql = "SELECT memid, userid, journalid, ditemid, $des security "
+            . "FROM memorable2 WHERE userid = ? $selwhere $secwhere $extrawhere";
+    $sth = $dbcr->prepare( $sql );
 
     # general execution and fetching for return
     $sth->execute($u->{userid});
@@ -599,41 +544,21 @@ sub get_by_keyword {
     my $kw = defined $kwoid && !$kwid ? $kwoid : undef;
     return undef unless $u && ($kwid || defined $kw);
 
-    # two entirely separate codepaths, depending on the user's dversion.
     my $memids;
-    if ($u->{dversion} > 5) {
-        # the smart way
-        my $dbcr = LJ::get_cluster_reader($u);
-        return undef unless $dbcr;
+    my $dbcr = LJ::get_cluster_reader( $u );
+    return undef unless $dbcr;
 
-        # get keyword id if we don't have it
-        if (defined $kw) {
-            $kwid = $dbcr->selectrow_array('SELECT kwid FROM userkeywords WHERE userid = ? AND keyword = ?',
-                                           undef, $u->{userid}, $kw)+0;
-        }
-        return undef unless $kwid;
+    # get keyword id if we don't have it
+    if ( defined $kw ) {
+        $kwid = $dbcr->selectrow_array( 'SELECT kwid FROM userkeywords WHERE userid = ? AND keyword = ?',
+                                        undef, $u->userid, $kw ) + 0;
+    }
+    return undef unless $kwid;
 
-        # now get the actual memory ids
-        $memids = $dbcr->selectcol_arrayref('SELECT memid FROM memkeyword2 WHERE userid = ? AND kwid = ?',
-                                           undef, $u->{userid}, $kwid);
-        return undef if $dbcr->err;
-    } else {
-        # the dumb way
-        my $dbr = LJ::get_db_reader();
-        return undef unless $dbr;
-
-        # get keyword id if we don't have it
-        if (defined $kw) {
-            $kwid = $dbr->selectrow_array('SELECT kwid FROM keywords WHERE keyword = ?', undef, $kw)+0;
-        }
-        return undef unless $kwid;
-
-        # now get memory ids.  this has to join.  :(
-        $memids = $dbr->selectcol_arrayref('SELECT m.memid FROM memorable m, memkeyword mk ' .
-                                           'WHERE m.userid = ? AND mk.memid = m.memid AND mk.kwid = ?',
-                                           undef, $u->{userid}, $kwid);
-        return undef if $dbr->err;
-    }
+    # now get the actual memory ids
+    $memids = $dbcr->selectcol_arrayref( 'SELECT memid FROM memkeyword2 WHERE userid = ? AND kwid = ?',
+                                         undef, $u->{userid}, $kwid );
+    return undef if $dbcr->err;
 
     # return
     $memids = [] unless defined($memids);
@@ -660,47 +585,19 @@ sub get_keywords {
     return $ret if defined $ret;
     $ret = {};
 
-    if ($u->{dversion} > 5) {
-        # new style clustered code
-        my $dbcm = LJ::get_cluster_def_reader($u);
-        unless ($dbcm) {
-            $use_reader = 1;
-            $dbcm = LJ::get_cluster_reader($u);
-        }
-        my $ids = $dbcm->selectcol_arrayref('SELECT DISTINCT kwid FROM memkeyword2 WHERE userid = ?',
-                                            undef, $u->{userid});
-        if (@{$ids || []}) {
-            my $in = join ",", @$ids;
-            my $rows = $dbcm->selectall_arrayref('SELECT kwid, keyword FROM userkeywords ' .
-                                                 "WHERE userid = ? AND kwid IN ($in)", undef, $u->{userid});
-            $ret->{$_->[0]} = $_->[1] foreach @{$rows || []};
-        }
-
-    } else {
-        # old style code using global
-        my $dbh = LJ::get_db_writer();
-        unless ($dbh) {
-            $use_reader = 1;
-            $dbh = LJ::get_db_reader();
-        }
-        my $sth = $dbh->prepare("SELECT DISTINCT mk.kwid ".
-                                "FROM ".
-                                "  memorable m FORCE INDEX (uniq),".
-                                "  memkeyword mk ".
-                                "WHERE mk.memid=m.memid AND m.userid=?");
-        $sth->execute($u->{userid});
-        my @ids;
-        push @ids, $_ while $_ = $sth->fetchrow_array;
-
-        if (@ids) {
-            my $in = join(",", @ids);
-            $sth = $dbh->prepare("SELECT kwid, keyword FROM keywords WHERE kwid IN ($in)");
-            $sth->execute;
-
-            while (my ($id,$kw) = $sth->fetchrow_array) {
-                $ret->{$id} = $kw;
-            }
-        }
+    my $dbcm = LJ::get_cluster_def_reader( $u );
+    unless ( $dbcm ) {
+        $use_reader = 1;
+        $dbcm = LJ::get_cluster_reader( $u );
+    }
+    my $ids = $dbcm->selectcol_arrayref( 'SELECT DISTINCT kwid FROM memkeyword2 WHERE userid = ?',
+                                         undef, $u->userid );
+    if ( @{$ids || []} ) {
+        my $in = join ",", @$ids;
+        my $rows = $dbcm->selectall_arrayref( 'SELECT kwid, keyword FROM userkeywords ' .
+                                              "WHERE userid = ? AND kwid IN ($in)",
+                                              undef, $u->userid );
+        $ret->{$_->[0]} = $_->[1] foreach @{$rows || []};
     }
 
     my $expiration = $LJ::MEMCACHE_EXPIRATION{'memkwid'} || 86400;
diff -r c7dfa9c29068 -r 00706993500e cgi-bin/ljuserpics.pl
--- a/cgi-bin/ljuserpics.pl	Sat Sep 05 12:12:35 2009 +0000
+++ b/cgi-bin/ljuserpics.pl	Sat Sep 05 14:35:14 2009 +0000
@@ -70,16 +70,11 @@ sub load_userpics
     }
 
     my %db_load;
-    my @load_list_d6;
     foreach my $row (@load_list) {
         # ignore users on clusterid 0
         next unless $row->[0]->{clusterid};
 
-        if ($row->[0]->{'dversion'} > 6) {
-            push @{$db_load{$row->[0]->{'clusterid'}}}, $row;
-        } else {
-            push @load_list_d6, $row;
-        }
+        push @{$db_load{$row->[0]->{clusterid}}}, $row;
     }
 
     foreach my $cid (keys %db_load) {
@@ -115,36 +110,6 @@ sub load_userpics
             LJ::MemCache::set([$id,"userpic.$id"], LJ::MemCache::hash_to_array("userpic", $ur));
         }
     }
-
-    # following path is only for old style d6 userpics... don't load any if we don't
-    # have any to load
-    return unless @load_list_d6;
-
-    my $dbr = LJ::get_db_writer();
-    my $picid_in = join(',', map { $_->[1] } @load_list_d6);
-    my $sth = $dbr->prepare("SELECT userid, picid, width, height, contenttype, state, ".
-                            "       UNIX_TIMESTAMP(picdate) AS 'picdate' ".
-                            "FROM userpic WHERE picid IN ($picid_in)");
-    $sth->execute;
-    while (my $ur = $sth->fetchrow_hashref) {
-        my $id = delete $ur->{'picid'};
-        $upics->{$id} = $ur;
-
-        # force into numeric context so they'll be smaller in memcache:
-        foreach my $k (qw(userid width height picdate)) {
-            $ur->{$k} += 0;
-        }
-        $ur->{location} = "?";
-        $ur->{flags} = undef;
-        $ur->{fmt} = {
-            'image/gif' => 'G',
-            'image/jpeg' => 'J',
-            'image/png' => 'P',
-        }->{delete $ur->{contenttype}};
-
-        $LJ::CACHE_USERPIC{$id} = $ur;
-        LJ::MemCache::set([$id,"userpic.$id"], LJ::MemCache::hash_to_array("userpic", $ur));
-    }
 }
 
 # <LJFUNC>
@@ -167,42 +132,25 @@ sub expunge_userpic {
     # get the pic information
     my $state;
 
-    if ($u->{'dversion'} > 6) {
-        my $dbcm = LJ::get_cluster_master($u);
-        return undef unless $dbcm && $u->writer;
+    my $dbcm = LJ::get_cluster_master( $u );
+    return undef unless $dbcm && $u->writer;
 
-        $state = $dbcm->selectrow_array('SELECT state FROM userpic2 WHERE userid = ? AND picid = ?',
-                                        undef, $u->{'userid'}, $picid);
-        return undef unless $state; # invalid pic
-        return $u->{'userid'} if $state eq 'X'; # already expunged
+    $state = $dbcm->selectrow_array( 'SELECT state FROM userpic2 WHERE userid = ? AND picid = ?',
+                                     undef, $u->userid, $picid );
+    return undef unless $state; # invalid pic
+    return $u->userid if $state eq 'X'; # already expunged
 
-        # else now mark it
-        $u->do("UPDATE userpic2 SET state='X' WHERE userid = ? AND picid = ?", undef, $u->{'userid'}, $picid);
-        return LJ::error($dbcm) if $dbcm->err;
-        $u->do("DELETE FROM userpicmap2 WHERE userid = ? AND picid = ?", undef, $u->{'userid'}, $picid);
-    } else {
-        my $dbr = LJ::get_db_reader();
-        return undef unless $dbr;
-
-        $state = $dbr->selectrow_array('SELECT state FROM userpic WHERE picid = ?',
-                                       undef, $picid);
-        return undef unless $state; # invalid pic
-        return $u->{'userid'} if $state eq 'X'; # already expunged
-
-        # else now mark it
-        my $dbh = LJ::get_db_writer();
-        return undef unless $dbh;
-        $dbh->do("UPDATE userpic SET state='X' WHERE picid = ?", undef, $picid);
-        return LJ::error($dbh) if $dbh->err;
-        $dbh->do("DELETE FROM userpicmap WHERE userid = ? AND picid = ?", undef, $u->{'userid'}, $picid);
-    }
+    # else now mark it
+    $u->do( "UPDATE userpic2 SET state='X' WHERE userid = ? AND picid = ?", undef, $u->userid, $picid );
+    return LJ::error( $dbcm ) if $dbcm->err;
+    $u->do( "DELETE FROM userpicmap2 WHERE userid = ? AND picid = ?", undef, $u->userid, $picid );
 
     # now clear the user's memcache picture info
-    LJ::Userpic->delete_cache($u);
+    LJ::Userpic->delete_cache( $u );
 
     # call the hook and get out of here
-    my @rval = LJ::run_hooks('expunge_userpic', $picid, $u->{'userid'});
-    return ($u->{'userid'}, map {$_->[0]} grep {$_ && @$_ && $_->[0]} @rval);
+    my @rval = LJ::run_hooks( 'expunge_userpic', $picid, $u->userid );
+    return ( $u->userid, map {$_->[0]} grep {$_ && @$_ && $_->[0]} @rval );
 }
 
 # <LJFUNC>
@@ -255,11 +203,10 @@ sub get_userpic_info
     # and we need them
     if (my $cachedata = $LJ::CACHE_USERPIC_INFO{$userid}) {
         my $good = 1;
-        if ($u->{'dversion'} > 6) {
-            $good = 0 if $opts->{'load_comments'} && ! $cachedata->{'_has_comments'};
-            $good = 0 if $opts->{'load_urls'} && ! $cachedata->{'_has_urls'};
-            $good = 0 if $opts->{'load_descriptions'} && ! $cachedata->{'_has_descriptions'};
-        }
+        $good = 0 if $opts->{load_comments} && ! $cachedata->{_has_comments};
+        $good = 0 if $opts->{load_urls} && ! $cachedata->{_has_urls};
+        $good = 0 if $opts->{load_descriptions} && ! $cachedata->{_has_descriptions};
+
         return $cachedata if $good;
     }
 
@@ -300,71 +247,68 @@ sub get_userpic_info
             }
         }
 
-        if ($u->{'dversion'} > 6) {
+        # Load picture comments
+        if ( $opts->{load_comments} ) {
+            my $commemkey = [$u->userid, "upiccom:" . $u->userid];
+            my $comminfo = LJ::MemCache::get( $commemkey );
 
-            # Load picture comments
-            if ( $opts->{'load_comments'} ) {
-                my $commemkey = [$u->{'userid'}, "upiccom:$u->{'userid'}"];
-                my $comminfo = LJ::MemCache::get($commemkey);
+            if ( defined( $comminfo ) ) {
+                my ( $pos, $nulpos );
+                $pos = $nulpos = 0;
+                while ( ($nulpos = index( $comminfo, "\0", $pos )) > 0 ) {
+                    my $comment = substr( $comminfo, $pos, $nulpos-$pos );
+                    my $id = unpack( "N", substr( $comminfo, $nulpos+1, 4 ) );
+                    $pos = $nulpos + 5; # skip NUL + 4 bytes.
+                    $info->{pic}->{$id}->{comment} = $comment;
+                    $info->{comment}->{$id} = $comment;
+                }
+                $info->{_has_comments} = 1;
+            } else { # Requested to load comments, but they aren't in memcache
+                     # so force a db load
+                undef $info;
+            }
+        }
 
-                if ( defined( $comminfo ) ) {
-                    my ($pos, $nulpos);
-                    $pos = $nulpos = 0;
-                    while (($nulpos = index($comminfo, "\0", $pos)) > 0) {
-                        my $comment = substr($comminfo, $pos, $nulpos-$pos);
-                        my $id = unpack("N", substr($comminfo, $nulpos+1, 4));
-                        $pos = $nulpos + 5; # skip NUL + 4 bytes.
-                        $info->{'pic'}->{$id}->{'comment'} = $comment;
-                        $info->{'comment'}->{$id} = $comment;
-                    }
-                    $info->{'_has_comments'} = 1;
-                } else { # Requested to load comments, but they aren't in memcache
-                         # so force a db load
-                    undef $info;
+        # Load picture urls
+        if ( $opts->{load_urls} && $info ) {
+            my $urlmemkey = [$u->userid, "upicurl:" . $u->userid];
+            my $urlinfo = LJ::MemCache::get( $urlmemkey );
+
+            if ( defined( $urlinfo ) ) {
+                my ( $pos, $nulpos );
+                $pos = $nulpos = 0;
+                while ( ($nulpos = index( $urlinfo, "\0", $pos )) > 0 ) {
+                    my $url = substr( $urlinfo, $pos, $nulpos-$pos );
+                    my $id = unpack( "N", substr( $urlinfo, $nulpos+1, 4 ) );
+                    $pos = $nulpos + 5; # skip NUL + 4 bytes.
+                    $info->{pic}->{$id}->{url} = $url;
                 }
+                $info->{_has_urls} = 1;
+            } else { # Requested to load urls, but they aren't in memcache
+                     # so force a db load
+                undef $info;
             }
+        }
 
-            # Load picture urls
-            if ( $opts->{'load_urls'} && $info ) {
-                my $urlmemkey = [$u->{'userid'}, "upicurl:$u->{'userid'}"];
-                my $urlinfo = LJ::MemCache::get($urlmemkey);
+        # Load picture descriptions
+        if ( $opts->{load_descriptions} && $info ) {
+            my $descmemkey = [$u->userid, "upicdes:" . $u->userid];
+            my $descinfo = LJ::MemCache::get( $descmemkey );
 
-                if ( defined( $urlinfo ) ) {
-                    my ($pos, $nulpos);
-                    $pos = $nulpos = 0;
-                    while (($nulpos = index($urlinfo, "\0", $pos)) > 0) {
-                        my $url = substr($urlinfo, $pos, $nulpos-$pos);
-                        my $id = unpack("N", substr($urlinfo, $nulpos+1, 4));
-                        $pos = $nulpos + 5; # skip NUL + 4 bytes.
-                        $info->{'pic'}->{$id}->{'url'} = $url;
-                    }
-                    $info->{'_has_urls'} = 1;
-                } else { # Requested to load urls, but they aren't in memcache
-                         # so force a db load
-                    undef $info;
+            if ( defined ( $descinfo ) ) {
+                my ( $pos, $nulpos );
+                $pos = $nulpos = 0;
+                while ( ($nulpos = index( $descinfo, "\0", $pos )) > 0 ) {
+                    my $description = substr( $descinfo, $pos, $nulpos-$pos );
+                    my $id = unpack( "N", substr( $descinfo, $nulpos+1, 4 ) );
+                    $pos = $nulpos + 5; # skip NUL + 4 bytes.
+                    $info->{pic}->{$id}->{description} = $description;
+                    $info->{description}->{$id} = $description;
                 }
-            }
-
-            # Load picture descriptions
-            if ( $opts->{'load_descriptions'} && $info ) {
-                my $descmemkey = [$u->{'userid'}, "upicdes:$u->{'userid'}"];
-                my $descinfo = LJ::MemCache::get($descmemkey);
-
-                if ( defined ( $descinfo ) ) {
-                    my ($pos, $nulpos);
-                    $pos = $nulpos = 0;
-                    while (($nulpos = index($descinfo, "\0", $pos)) > 0) {
-                        my $description = substr($descinfo, $pos, $nulpos-$pos);
-                        my $id = unpack("N", substr($descinfo, $nulpos+1, 4));
-                        $pos = $nulpos + 5; # skip NUL + 4 bytes.
-                        $info->{pic}->{$id}->{description} = $description;
-                        $info->{description}->{$id} = $description;
-                    }
-                    $info->{'_has_descriptions'} = 1;
-                } else { # Requested to load descriptions, but they aren't in memcache
-                         # so force a db load
-                    undef $info;
-                }
+                $info->{_has_descriptions} = 1;
+            } else { # Requested to load descriptions, but they aren't in memcache
+                     # so force a db load
+                undef $info;
             }
         }
     }
@@ -383,38 +327,28 @@ sub get_userpic_info
         my $db = @LJ::MEMCACHE_SERVERS ? LJ::get_db_writer() : LJ::get_db_reader();
         return undef unless $dbcr && $db;
 
-        if ($u->{'dversion'} > 6) {
-            $sth = $dbcr->prepare("SELECT picid, width, height, state, userid, comment, url, description ".
-                                  "FROM userpic2 WHERE userid=?");
-        } else {
-            $sth = $db->prepare("SELECT picid, width, height, state, userid ".
-                                "FROM userpic WHERE userid=?");
-        }
-        $sth->execute($u->{'userid'});
+        $sth = $dbcr->prepare( "SELECT picid, width, height, state, userid, comment, url, description ".
+                               "FROM userpic2 WHERE userid=?" );
+        $sth->execute( $u->userid );
         my @pics;
         while (my $pic = $sth->fetchrow_hashref) {
             next if $pic->{state} eq 'X'; # no expunged pics in list
             push @pics, $pic;
             $info->{'pic'}->{$pic->{'picid'}} = $pic;
-            $minfocom{int($pic->{picid})} = $pic->{comment} if $u->{'dversion'} > 6
-                && $opts->{'load_comments'} && $pic->{'comment'};
-            $minfourl{int($pic->{'picid'})} = $pic->{'url'} if $u->{'dversion'} > 6
-                && $opts->{'load_urls'} && $pic->{'url'};
-            $minfodesc{int($pic->{picid})} = $pic->{description} if $u->{dversion} > 6
-                && $opts->{load_descriptions} && $pic->{description}; 
+            $minfocom{int($pic->{picid})} = $pic->{comment}
+                if $opts->{load_comments} && $pic->{comment};
+            $minfourl{int($pic->{picid})} = $pic->{url}
+                if $opts->{load_urls} && $pic->{url};
+            $minfodesc{int($pic->{picid})} = $pic->{description}
+                if $opts->{load_descriptions} && $pic->{description}; 
         }
 
 
         $picstr = join('', map { pack("NCCA", $_->{picid},
                                  $_->{width}, $_->{height}, $_->{state}) } @pics);
 
-        if ($u->{'dversion'} > 6) {
-            $sth = $dbcr->prepare("SELECT k.keyword, m.picid FROM userpicmap2 m, userkeywords k ".
-                                  "WHERE k.userid=? AND m.kwid=k.kwid AND m.userid=k.userid");
-        } else {
-            $sth = $db->prepare("SELECT k.keyword, m.picid FROM userpicmap m, keywords k ".
-                                "WHERE m.userid=? AND m.kwid=k.kwid");
-        }
+        $sth = $dbcr->prepare( "SELECT k.keyword, m.picid FROM userpicmap2 m, userkeywords k ".
+                               "WHERE k.userid=? AND m.kwid=k.kwid AND m.userid=k.userid" );
         $sth->execute($u->{'userid'});
         my %minfokw;
         while (my ($kw, $id) = $sth->fetchrow_array) {
@@ -429,40 +363,37 @@ sub get_userpic_info
         $minfo = [ $VERSION_PICINFO, $picstr, $kwstr ];
         LJ::MemCache::set($memkey, $minfo);
 
-        if ($u->{'dversion'} > 6) {
+        if ( $opts->{load_comments} ) {
+            $info->{comment} = \%minfocom;
+            my $commentstr = join( '', map { pack( "Z*N", $minfocom{$_}, $_ ) } keys %minfocom );
 
-            if ($opts->{'load_comments'}) {
-                $info->{'comment'} = \%minfocom;
-                my $commentstr = join('', map { pack("Z*N", $minfocom{$_}, $_) } keys %minfocom);
+            my $memkey = [$u->userid, "upiccom:" . $u->userid];
+            LJ::MemCache::set( $memkey, $commentstr );
 
-                my $memkey = [$u->{'userid'}, "upiccom:$u->{'userid'}"];
-                LJ::MemCache::set($memkey, $commentstr);
+            $info->{_has_comments} = 1;
+        }
 
-                $info->{'_has_comments'} = 1;
-            }
+        if ($opts->{load_urls}) {
+            my $urlstr = join( '', map { pack( "Z*N", $minfourl{$_}, $_ ) } keys %minfourl );
 
-            if ($opts->{'load_urls'}) {
-                my $urlstr = join('', map { pack("Z*N", $minfourl{$_}, $_) } keys %minfourl);
+            my $memkey = [$u->userid, "upicurl:" . $u->userid];
+            LJ::MemCache::set( $memkey, $urlstr );
 
-                my $memkey = [$u->{'userid'}, "upicurl:$u->{'userid'}"];
-                LJ::MemCache::set($memkey, $urlstr);
+            $info->{_has_urls} = 1;
+        }
 
-                $info->{'_has_urls'} = 1;
-            }
-            
-            if ($opts->{load_descriptions}) {
-                $info->{description} = \%minfodesc;
-                my $descstring = join('', map { pack("Z*N", $minfodesc{$_}, $_) } keys %minfodesc);
+        if ($opts->{load_descriptions}) {
+            $info->{description} = \%minfodesc;
+            my $descstring = join( '', map { pack( "Z*N", $minfodesc{$_}, $_ ) } keys %minfodesc );
 
-                my $memkey = [$u->{'userid'}, "upicdes:$u->{'userid'}"];
-                LJ::MemCache::set($memkey, $descstring);
+            my $memkey = [$u->userid, "upicdes:" $u->userid];
+            LJ::MemCache::set( $memkey, $descstring );
 
-                $info->{'_has_descriptions'} = 1;
-            }
+            $info->{_has_descriptions} = 1;
         }
     }
 
-    $LJ::CACHE_USERPIC_INFO{$u->{'userid'}} = $info;
+    $LJ::CACHE_USERPIC_INFO{$u->userid} = $info;
     return $info;
 }
 
diff -r c7dfa9c29068 -r 00706993500e htdocs/editpics.bml
--- a/htdocs/editpics.bml	Sat Sep 05 12:12:35 2009 +0000
+++ b/htdocs/editpics.bml	Sat Sep 05 14:35:14 2009 +0000
@@ -365,17 +365,15 @@ use strict;
             $body .= "</p>\n";
             $body .= "<p class='detail'>$ML{'.label.keywords.desc'}</p>\n";
 
-            if (LJ::Userpic->user_supports_comments($u)) {
-                $body .= "<p class='pkg'>\n";
-                $body .= "<label class='left' for='comments_0'>$ML{'.label.comment'}</label>\n";
-                my $comments = $POST{'comments'};
-                $body .= "<span class='input-wrapper'>";
-                $body .= LJ::html_text({ 'name' => 'comments_0', 'class' => 'text', id => 'comments_0', 'maxlength' => LJ::CMAX_UPIC_COMMENT, 'value', $comments }) . "\n";
-                $body .= LJ::help_icon_html('upic_comments') . "\n";
-                $body .= "</span>";
-                $body .= "</p>\n";
-                $body .= "<p class='detail'>$ML{'.label.comment.desc'}</p>\n";
-            }
+            $body .= "<p class='pkg'>\n";
+            $body .= "<label class='left' for='comments_0'>$ML{'.label.comment'}</label>\n";
+            my $comments = $POST{'comments'};
+            $body .= "<span class='input-wrapper'>";
+            $body .= LJ::html_text({ 'name' => 'comments_0', 'class' => 'text', id => 'comments_0', 'maxlength' => LJ::CMAX_UPIC_COMMENT, 'value', $comments }) . "\n";
+            $body .= LJ::help_icon_html('upic_comments') . "\n";
+            $body .= "</span>";
+            $body .= "</p>\n";
+            $body .= "<p class='detail'>$ML{'.label.comment.desc'}</p>\n";
 
             $body .= "<p class='pkg'>\n";
             $body .= "<label class='left' for='descriptions_0'>$ML{'.label.description'}</label>\n";
@@ -409,9 +407,7 @@ use strict;
                 $body .= "<input type='button' value='$ML{'.btn.addfile'}' onclick='javascript:addNewUpload(\"file\");' /> <input type='button' value='$ML{'.btn.addurl'}' onclick='javascript:addNewUpload(\"url\");'/>\n";
                 $body .= "<script type='text/javascript'>\n";
                 $body .= "maxcounter = $remaining_uploads;\n";
-                if (LJ::Userpic->user_supports_comments($u)) {
-                    $body .= "allowComments = true;\n";
-                }
+                $body .= "allowComments = true;\n";
                 $body .= "allowDescriptions = true;\n";
 
                 $body .= "ep_labels.comment = '$ML{'.label.comment'}';\n";
@@ -498,18 +494,16 @@ use strict;
                                        'value' => $keywords }) . "\n";
             $body .= "</div>\n";
 
-            if ($pic->supports_comments) {
-                $body .= "<div class='userpic_comments pkg'>\n";
-                $body .= "<label class='left' for='com_$pid'>$ML{'.label.comment'}</label>\n ";
-                $body .= LJ::html_text({ 'name' => "com_$pid", 'class' => "text", 'id' => "com_$pid",
-                                         'value' => $comment,
-                                         'maxlength' => LJ::CMAX_UPIC_COMMENT,
-                                         'disabled' => $pic->inactive }) . "\n";
-                $body .= LJ::html_hidden({ 'name' => "com_orig_$pid",
-                                           'value' => $comment }) . "\n";
+            $body .= "<div class='userpic_comments pkg'>\n";
+            $body .= "<label class='left' for='com_$pid'>$ML{'.label.comment'}</label>\n ";
+            $body .= LJ::html_text({ 'name' => "com_$pid", 'class' => "text", 'id' => "com_$pid",
+                                     'value' => $comment,
+                                     'maxlength' => LJ::CMAX_UPIC_COMMENT,
+                                     'disabled' => $pic->inactive }) . "\n";
+            $body .= LJ::html_hidden({ 'name' => "com_orig_$pid",
+                                       'value' => $comment }) . "\n";
 
-                $body .= "</div>\n";
-            }
+            $body .= "</div>\n";
             
             $body .= "<div class='userpic_descriptions pkg'>\n";
             $body .= "<label class='left' for='desc_$pid'>$ML{'.label.description'}</label>\n ";
--------------------------------------------------------------------------------