fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-09-29 04:17 pm

[dw-free] move cgi-bin/lj*.pl files into proper modules (in cgi-bin/LJ)

[commit: http://hg.dwscoalition.org/dw-free/rev/165dda86a14f]

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

Cleanup whitespace.

Patch by [personal profile] kareila.

Files modified:
  • bin/ljdb
  • bin/moveucluster.pl
  • cgi-bin/LJ/Entry.pm
  • cgi-bin/LJ/Lang.pm
  • cgi-bin/LJ/UniqCookie.pm
  • cgi-bin/LJ/User.pm
  • t/uniqcookie.t
--------------------------------------------------------------------------------
diff -r 5cf79cb7d354 -r 165dda86a14f bin/ljdb
--- a/bin/ljdb	Fri Sep 30 00:14:15 2011 +0800
+++ b/bin/ljdb	Fri Sep 30 00:15:37 2011 +0800
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by 
+# by Live Journal, Inc. The code has been modified and expanded by
 # Dreamwidth Studios, LLC. These files were originally licensed under
 # the terms of the license supplied by Live Journal, Inc, which can
 # currently be found at:
@@ -8,7 +8,7 @@
 # http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
 #
 # In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License. 
+# modifications are provided under the GNU General Public License.
 # A copy of that license can be found in the LICENSE file included as
 # part of this distribution.
 #
@@ -56,7 +56,7 @@
         usage();
     }
 }
-        
+
 usage() if $role && ($user || $inactive);
 
 print "For more usage options, see: ljdb --help\n";
diff -r 5cf79cb7d354 -r 165dda86a14f bin/moveucluster.pl
--- a/bin/moveucluster.pl	Fri Sep 30 00:14:15 2011 +0800
+++ b/bin/moveucluster.pl	Fri Sep 30 00:15:37 2011 +0800
@@ -508,7 +508,7 @@
 
         print "Expunging user '$u->{'user'}'\n";
         $dbh->do("INSERT INTO clustermove (userid, sclust, dclust, timestart, timedone) ".
-                 "VALUES (?,?,?,UNIX_TIMESTAMP(),UNIX_TIMESTAMP())", undef, 
+                 "VALUES (?,?,?,UNIX_TIMESTAMP(),UNIX_TIMESTAMP())", undef,
                  $userid, $sclust, 0);
 
         $u->update_self( { clusterid => 0,
diff -r 5cf79cb7d354 -r 165dda86a14f cgi-bin/LJ/Entry.pm
--- a/cgi-bin/LJ/Entry.pm	Fri Sep 30 00:14:15 2011 +0800
+++ b/cgi-bin/LJ/Entry.pm	Fri Sep 30 00:15:37 2011 +0800
@@ -265,7 +265,7 @@
     my $self = $_[0];
 
     my $alttext = LJ::Lang::ml('setting.xpost.option.footer.vars.comment_image.alt');
-    
+
     return '<img src="' . $self->comment_image_url . '" width="30" height="12" alt="' . $alttext . '" style="vertical-align: middle;"/>';
 }
 
@@ -827,7 +827,7 @@
         # check if it's a community and they're a member
         return 1 if $self->journal->is_community &&
                 $remote->member_of( $self->journal );
-    
+
         my $gmask = $self->journal->trustmask( $remote );
         my $allowed = (int($gmask) & int($self->{'allowmask'}));
         return $allowed ? 1 : 0;  # no need to return matching mask
@@ -876,7 +876,7 @@
     my $self = $_[0];
 
     my $up = $self->poster;
-    
+
     my $key;
     # try their entry-defined userpic keyword
     if ( $up->userpic_have_mapid ) {
diff -r 5cf79cb7d354 -r 165dda86a14f cgi-bin/LJ/Lang.pm
--- a/cgi-bin/LJ/Lang.pm	Fri Sep 30 00:14:15 2011 +0800
+++ b/cgi-bin/LJ/Lang.pm	Fri Sep 30 00:15:37 2011 +0800
@@ -501,7 +501,7 @@
     my $lang;
     if (LJ::is_web_context()) {
         $lang = BML::get_language();
-    } 
+    }
     if (my $remote = LJ::get_remote()) {
         # we have a user; try their browse language
         $lang ||= $remote->prop("browselang");
@@ -553,7 +553,7 @@
 {
     my ($lang, $code, $dmid, $vars) = @_;
     $lang ||= $LJ::DEFAULT_LANG;
-    
+
     my $from_db = sub {
         my $text = get_text_multi($lang, $dmid, [ $code ]);
         return $text->{$code};
@@ -633,16 +633,16 @@
     ##  Codes in disk .text files, mysql and bml files may be mixed-cased
     ##  Codes in memcache and %TXT_CACHE are lower-case
     ##  Codes are not case-sensitive
-    
+
     ## %lc_code: lower-case code --> original code
     my %lc_codes = map { lc($_) => $_ } @$codes;
-    
+
     ## %memkeys: lower-case code --> memcache key
-    my %memkeys; 
+    my %memkeys;
     foreach my $code (keys %lc_codes) {
         my $cache_key = "ml.${lang}.${dmid}.${code}";
         my $text = $LJ::NO_ML_CACHE ? undef : $TXT_CACHE{$cache_key};
-        
+
         if (defined $text) {
             $strings{ $lc_codes{$code} } = $text;
             $LJ::_ML_USED_STRINGS{$code} = $text if $LJ::IS_DEV_SERVER;
@@ -660,7 +660,7 @@
     foreach my $cache_key (keys %memkeys) {
         my $code = $memkeys{$cache_key};
         my $text = $mem->{$cache_key};
-        
+
         if (defined $text) {
             $strings{ $lc_codes{$code} } = $text;
             $LJ::_ML_USED_STRINGS{$code} = $text if $LJ::IS_DEV_SERVER;
diff -r 5cf79cb7d354 -r 165dda86a14f cgi-bin/LJ/UniqCookie.pm
--- a/cgi-bin/LJ/UniqCookie.pm	Fri Sep 30 00:14:15 2011 +0800
+++ b/cgi-bin/LJ/UniqCookie.pm	Fri Sep 30 00:15:37 2011 +0800
@@ -42,7 +42,7 @@
         unless ref $uniq_list eq 'ARRAY';
 
     return $req_cache_uid2uniqs{$uid} = $uniq_list;
-} 
+}
 
 sub get_request_cache_by_user {
     my $class = shift;
@@ -73,7 +73,7 @@
     }
 
     $req_cache_uniq2uids{$uniq} = \@userids;
-} 
+}
 
 sub get_request_cache_by_uniq {
     my $class = shift;
@@ -106,7 +106,7 @@
 sub set_memcache_by_user {
     my $class = shift;
     my ($u_arg, $uniq_list) = @_;
-    
+
     my $uid = LJ::want_userid($u_arg)
         or croak "invalid user arg: $u_arg";
 
@@ -129,7 +129,7 @@
 sub set_memcache_by_uniq {
     my $class = shift;
     my ($uniq, $user_list) = @_;
-    
+
     croak "invalid 'uniq' argument: $uniq"
         unless length $uniq;
 
@@ -215,7 +215,7 @@
     if ($LJ::_T_UNIQCOOKIE_LAZY_CLEAN_PCT) {
         $pct = $LJ::_T_UNIQCOOKIE_LAZY_CLEAN_PCT;
     }
-    
+
     return rand() <= $pct;
 }
 
@@ -275,7 +275,7 @@
     # first, check request cache
     my $cache_val = $class->get_request_cache_by_user($uid);
     return @$cache_val if defined $cache_val;
-    
+
     # second, check memcache
     my $memval = $class->get_memcache_by_user($uid);
     if ($memval) {
@@ -288,7 +288,7 @@
 
     my $limit = $window_size + 1;
     my $sth = $dbh->prepare
-        ("SELECT uniq, modtime FROM uniqmap WHERE userid=? " . 
+        ("SELECT uniq, modtime FROM uniqmap WHERE userid=? " .
          "ORDER BY modtime DESC LIMIT $limit");
     $sth->execute($uid);
     die $dbh->errstr if $dbh->err;
@@ -303,7 +303,7 @@
     # has happened ... we'll clean that now
     my $delete_ct = 0;
     if (@uniq_list >= $limit) {
-        $delete_ct = $dbh->do("DELETE FROM uniqmap WHERE userid=? AND modtime<=?", 
+        $delete_ct = $dbh->do("DELETE FROM uniqmap WHERE userid=? AND modtime<=?",
                           undef, $uid, $min_modtime);
 
         @uniq_list = @uniq_list[0..$window_size-1];
@@ -330,7 +330,7 @@
     # first, check request cache
     my $cache_val = $class->get_request_cache_by_uniq($uniq);
     return @$cache_val if defined $cache_val;
-    
+
     # second, check memcache
     my $memval = $class->get_memcache_by_uniq($uniq);
     if ($memval) {
@@ -358,7 +358,7 @@
     # has happened ... we'll clean that now
     my $delete_ct = 0;
     if (@uid_list >= $limit) {
-        $delete_ct = $dbh->do("DELETE FROM uniqmap WHERE uniq=? AND modtime<=?", 
+        $delete_ct = $dbh->do("DELETE FROM uniqmap WHERE uniq=? AND modtime<=?",
                           undef, $uniq, $min_modtime);
 
         # trim the cached/returned value as well
@@ -394,7 +394,7 @@
 
     my $r = DW::Request->get;
     return unless $r;
-    
+
     my ($uniq, $uniq_time, $uniq_extra) = $class->parts_from_cookie;
 
     # set this uniq as our current
diff -r 5cf79cb7d354 -r 165dda86a14f cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Fri Sep 30 00:14:15 2011 +0800
+++ b/cgi-bin/LJ/User.pm	Fri Sep 30 00:15:37 2011 +0800
@@ -8880,7 +8880,7 @@
     # now, if there's a GET argument for tags, split those out
     if (exists $opts->{getargs}->{tag}) {
         my $tagfilter = $opts->{getargs}->{tag};
-        
+
         unless ( $tagfilter ) {
             $opts->{redir} = $u->journal_base . "/tag/";
             return;
diff -r 5cf79cb7d354 -r 165dda86a14f t/uniqcookie.t
--- a/t/uniqcookie.t	Fri Sep 30 00:14:15 2011 +0800
+++ b/t/uniqcookie.t	Fri Sep 30 00:15:37 2011 +0800
@@ -26,136 +26,136 @@
         my $u = temp_user();
         my $uniq = $get_uniq->();
         ok($class->save_mapping($uniq => $u), "saved mapping");
-        
+
         my $uid = $class->load_mapping( uniq => $uniq );
         ok($uid == $u->id, "loaded by uniq");
-        
+
         my $new_uniq = $class->load_mapping( user => $u );
         ok($new_uniq eq $uniq, "loaded by u ser");
-        
+
         $LJ::_T_UNIQCOOKIE_CURRENT_UNIQ = $uniq;
         my $g_remote = $class->guess_remote;
         ok( $u->equals( $g_remote ), "guessed correct remote" );
     }
-    
+
     { # multiple uniqs, same user
-        
+
         my $u = temp_user();
-        
+
         my @added_uniqs;
         foreach (1..5) {
             my $uniq = $get_uniq->();
             $class->save_mapping($uniq => $u);
             push @added_uniqs, $uniq;
         }
-        
+
         my @got_uniqs = $class->load_mapping( user => $u );
         ok(eq_set(\@added_uniqs, \@got_uniqs), "got multiple uniqs for a user");
     }
-    
+
     { # multiple users, same uniq
-        
+
         my $uniq = $get_uniq->();
-        
+
         my @userids;
         foreach (1..5) {
             my $u = temp_user();
-            
+
             $class->save_mapping($uniq => $u);
             push @userids, $u->id;
         }
-        
+
         my @got_userids = $class->load_mapping( uniq => $uniq );
         ok(eq_set(\@got_userids, \@userids), "got multiple users for a uniq");
     }
-    
+
     { # multiple uniqs, multiple users
         my $u = temp_user();
         my $u2 = temp_user();
-        
+
         my @uniq_added;
         my @uniq_added_u2;
         foreach (1..5) {
             my $uniq = $get_uniq->();
-            
+
             $class->save_mapping($uniq => $u);
             push @uniq_added, $uniq;
-            
+
             if (rand() > 0.5) {
                 $class->save_mapping($uniq => $u2);
                 push @uniq_added_u2, $uniq;
             }
         }
-        
+
         my @uniq_list = $class->load_mapping( user => $u );
         ok(eq_set(\@uniq_added, \@uniq_list), "saved some uniqs, got the same back");
-        
+
         my @uniq_list2 = $class->load_mapping( user => $u2 );
         ok(eq_set(\@uniq_added, \@uniq_list), "saved uniqs to another user, got the same back");
     }
-    
+
     # set up a delete callback which will tell us the number
     # of rows deleted in the last cleaning operation
-    
+
     my $last_delete_ct = 0;
     $LJ::_T_UNIQCOOKIE_DELETE_CB = sub {
         my ($type, $ct) = @_;
         $last_delete_ct = $ct;
     };
-    
+
     { # cleaning per-user
-        
+
         my $u = temp_user();
-        
+
         my @added_uniqs;
         foreach (1..25) {
             my $uniq = $get_uniq->();
             $class->save_mapping($uniq => $u);
             push @added_uniqs, $uniq;
         }
-        
+
         my @got_uniqs = $class->load_mapping( user => $u );
         my @added_trim = (reverse @added_uniqs)[0..9];
         ok(eq_set(\@added_trim, \@got_uniqs), "cleaned multiple uniqs for a user");
-        
+
         ok($last_delete_ct == 15, "deleted correct number of rows by user");
-        
+
         # shouldn't clean this time around
         LJ::DB::no_cache( sub {
             $class->clear_request_cache;
             $class->load_mapping( user => $u );
         } );
-        
+
         ok($last_delete_ct == 0, "loaded by user without redundant cleaning");
-        
+
     }
-    
+
     { # cleaning per-uniq
-        
+
         my $uniq = $get_uniq->();
-        
+
         my @userids;
         foreach (1..25) {
             my $u = temp_user();
-            
+
             $class->save_mapping($uniq => $u);
             push @userids, $u->id;
         }
-        
+
         my @got_userids = $class->load_mapping( uniq => $uniq );
         my @userids_trim = (reverse @userids)[0..9];
         ok(eq_set(\@userids_trim, \@got_userids), "cleaned multiple users for a uniq");
         ok($last_delete_ct == 15, "deleted correct number of rows by uniq");
-        
+
         # shouldn't clean this time around
         LJ::DB::no_cache( sub {
             $class->clear_request_cache;
             $class->load_mapping( uniq => $uniq );
         } );
-        
+
         ok($last_delete_ct == 0, "loaded by uniq without redundant cleaning");
     }
-    
+
     { # lazy cleaning
 
         my $u = temp_user();
--------------------------------------------------------------------------------