Clean up the cleanup hack

        Patch by sophie. 

diffs (120 lines):

diff -r c82e50960a23 -r 224ca2685a61 cgi-bin/LJ/ConfCheck/General.pm
--- a/cgi-bin/LJ/ConfCheck/General.pm   Sat May 16 11:32:24 2009 +0000
+++ b/cgi-bin/LJ/ConfCheck/General.pm   Sat May 16 12:00:45 2009 +0000
@@ -320,11 +320,6 @@ add_conf('$NEWUSER_CAPS',
 add_conf('$NEWUSER_CAPS',
          type => 'int',
          des => "Bitmask of capability classes that new users begin their 
accounts with.  By default users aren't in any capability classes and get only 
the default site-wide capabilities.  See also \%CAP.",
-         );
-
-add_conf('$NEW_ENTRY_CLEANUP_HACK',
-         type => "bool",
-         des => "OLD HISTORIC BAGGAGE: Do not use!  There used to be a bug 
where only parts of entries got deleted, then there was another bug with 
per-user number allocation.  Together, they forced this option to be made for 
awhile, where new entries (when this is on) would blow away any old data if 
part of it was still there but wasn't supposed to be.  This includes deleting 
comments tied to those old entries.",
          );
 
 add_conf('$QBUFFERD_DELAY',
diff -r c82e50960a23 -r 224ca2685a61 cgi-bin/ljdefaults.pl
--- a/cgi-bin/ljdefaults.pl     Sat May 16 11:32:24 2009 +0000
+++ b/cgi-bin/ljdefaults.pl     Sat May 16 12:00:45 2009 +0000
@@ -142,10 +142,6 @@
 
     # maximum number of friendofs to load/memcache (affects userinfo.bml 
display)
     $MAX_FRIENDOF_LOAD ||= 5000;
-
-    # whether to proactively delete any comments associated with an entry when 
we assign
-    # a new jitemid (see the big comment above 
LJ::Protocol::new_entry_cleanup_hack)
-    $NEW_ENTRY_CLEANUP_HACK ||= 0;
 
     # block size is used in stats generation code that gets n rows from the db 
at a time
     $STATS_BLOCK_SIZE ||= 10_000;
diff -r c82e50960a23 -r 224ca2685a61 cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl     Sat May 16 11:32:24 2009 +0000
+++ b/cgi-bin/ljprotocol.pl     Sat May 16 12:00:45 2009 +0000
@@ -23,10 +23,6 @@ use lib "$LJ::HOME/cgi-bin";
 use lib "$LJ::HOME/cgi-bin";
 
 require "taglib.pl";
-
-# have to do this else mailgate will croak with email posting, but only want
-# to do it if the site has enabled the hack
-require "talklib.pl" if $LJ::NEW_ENTRY_CLEANUP_HACK;
 
 #### New interface (meta handler) ... other handlers should call into this.
 package LJ::Protocol;
@@ -1357,10 +1353,6 @@ sub postevent
     LJ::Entry->can("dostuff");
     LJ::replycount_do($uowner, $jitemid, "init");
 
-    # remove comments and logprops on new entry ... see comment by this sub 
for clarification
-    LJ::Protocol::new_entry_cleanup_hack($u, $jitemid) if 
$LJ::NEW_ENTRY_CLEANUP_HACK;
-    my $verb = $LJ::NEW_ENTRY_CLEANUP_HACK ? 'REPLACE' : 'INSERT';
-
     my $dberr;
     $uowner->log2_do(\$dberr, "INSERT INTO log2 (journalid, jitemid, posterid, 
eventtime, logtime, security, ".
                      "allowmask, replycount, year, month, day, revttime, 
rlogtime, anum) ".
@@ -1417,7 +1409,7 @@ sub postevent
     my $bytes = length($event) + length($req->{'subject'});
     $uowner->dudata_set('L', $jitemid, $bytes);
 
-    $uowner->do("$verb INTO logtext2 (journalid, jitemid, subject, event) ".
+    $uowner->do("INSERT INTO logtext2 (journalid, jitemid, subject, event) ".
                 "VALUES ($ownerid, $jitemid, ?, ?)", undef, $req->{'subject'},
                 LJ::text_compress($event));
     if ($uowner->err) {
@@ -2769,43 +2761,6 @@ sub fail
     return undef;
 }
 
-# PROBLEM: a while back we used auto_increment fields in our tables so that we 
could have
-# automatically incremented itemids and such.  this was eventually phased out 
in favor of
-# the more portable alloc_user_counter function which uses the 'counter' 
table.  when the
-# counter table has no data, it finds the highest id already in use in the 
database and adds
-# one to it.
-#
-# a problem came about when users who last posted before alloc_user_counter 
went
-# and deleted all their entries and posted anew.  alloc_user_counter would 
find no entries,
-# this no ids, and thus assign id 1, thinking it's all clean and new.  but, id 
1 had been
-# used previously, and now has comments attached to it.
-#
-# the comments would happen because there was an old bug that wouldn't delete 
comments when
-# an entry was deleted.  this has since been fixed.  so this all combines to 
make this
-# a necessity, at least until no buggy data exist anymore!
-#
-# this code here removes any comments that happen to exist for the id we're 
now using.
-sub new_entry_cleanup_hack {
-    my ($u, $jitemid) = @_;
-
-    # sanitize input
-    $jitemid += 0;
-    return unless $jitemid;
-    my $ownerid = LJ::want_userid($u);
-    return unless $ownerid;
-
-    # delete logprops
-    $u->do("DELETE FROM logprop2 WHERE journalid=$ownerid AND 
jitemid=$jitemid");
-
-    # delete comments
-    my $ids = LJ::Talk::get_talk_data($u, 'L', $jitemid);
-    return unless ref $ids eq 'HASH' && %$ids;
-    my $list = join ',', map { $_+0 } keys %$ids;
-    $u->do("DELETE FROM talk2 WHERE journalid=$ownerid AND jtalkid IN 
($list)");
-    $u->do("DELETE FROM talktext2 WHERE journalid=$ownerid AND jtalkid IN 
($list)");
-    $u->do("DELETE FROM talkprop2 WHERE journalid=$ownerid AND jtalkid IN 
($list)");
-}
-
 sub un_utf8_request {
     my $req = shift;
     $req->{$_} = LJ::no_utf8_flag($req->{$_}) foreach qw(subject event);
diff -r c82e50960a23 -r 224ca2685a61 doc/raw/build/ljconfig/ljconfig2db.pl
--- a/doc/raw/build/ljconfig/ljconfig2db.pl     Sat May 16 11:32:24 2009 +0000
+++ b/doc/raw/build/ljconfig/ljconfig2db.pl     Sat May 16 12:00:45 2009 +0000
@@ -1159,9 +1159,6 @@ Please see <a href='http://status.exa
             'fix_usercounter_enabled' => {
                     'desc' => "<emphasis role='strong'>Old historic baggage: 
Do not use.</emphasis> This boolean enables the 
<filename>fix_usercounter.bml</filename> tool at \$SITEROOT/admin. The tool 
reset user counters to resolve <quote>duplicate key error</quote> issues with 
journals. A better way to address the problem was found, making this tool 
redundant.",
             },
-            'new_entry_cleanup_hack' => {
-                    'desc' => "<emphasis role='strong'>Old historic baggage: 
Do not use.</emphasis>  There used to be a bug where only parts of entries got 
deleted, then there was another bug with per-user number allocation.  Together, 
they forced this option to be made for awhile, where new entries (when this is 
on) would blow away any old data if part of it was still there but wasn't 
supposed to be.  This includes deleting comments tied to those old entries. Off 
by default.",
-            },
         },
 
         'site_maintenance' => {
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to