fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-12-28 12:54 pm

[dw-free] move LJ::user_search_display to weblib.pl

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

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

Hush warnings that used to be silenced back when the function was in
LJ::User.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/weblib.pl
--------------------------------------------------------------------------------
diff -r 5df591a35dac -r b113414a301b cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Tue Dec 28 20:49:07 2010 +0800
+++ b/cgi-bin/weblib.pl	Tue Dec 28 20:54:20 2010 +0800
@@ -511,14 +511,18 @@ sub user_search_display {
     # username we can load it for a subset of users later,
     # if paginating.
     my $updated;
-    my @display;
+    my $disp_sort;
 
     if ($args{timesort}) {
         $updated = LJ::get_timeupdate_multi(keys %$loaded_users);
-        @display = sort { $updated->{$b->{userid}} <=> $updated->{$a->{userid}} } values %$loaded_users;
+        my $def_upd = sub { $updated->{$_[0]->userid} || 0 };
+        # let undefined values be zero for sorting purposes
+        $disp_sort = sub { $def_upd->($b) <=> $def_upd->($a) };
     } else {
-        @display = sort { $a->{user} cmp $b->{user} } values %$loaded_users;
+        $disp_sort = sub { $a->{user} cmp $b->{user} };
     }
+
+    my @display = sort $disp_sort values %$loaded_users;
 
     if (defined $args{perpage}) {
         my %items = LJ::paging( \@display, $args{curpage}, $args{perpage} );
@@ -589,8 +593,9 @@ sub user_search_display {
 
         $ret .= "<tr><td colspan='2' style='text-align: left; font-size: smaller' class='lastupdated'>";
 
-        if ( $updated->{$u->userid} > 0 ) {
-            $ret .= LJ::Lang::ml( 'search.user.update.last', { time => LJ::diff_ago_text( $updated->{$u->id} ) } );
+        my $upd = $updated->{$u->userid};
+        if ( defined $upd && $upd > 0 ) {
+            $ret .= LJ::Lang::ml( 'search.user.update.last', { time => LJ::diff_ago_text( $upd ) } );
         } else {
             $ret .= LJ::Lang::ml( 'search.user.update.never' );
         }
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org