[dw-free] cleaning up userpics code
[commit: http://hg.dwscoalition.org/dw-free/rev/d40a6121b525]
http://bugs.dwscoalition.org/show_bug.cgi?id=513
Also be able to retrieve expunged userpics.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=513
Also be able to retrieve expunged userpics.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Userpic.pm
-------------------------------------------------------------------------------- diff -r 794521415285 -r d40a6121b525 cgi-bin/LJ/Userpic.pm --- a/cgi-bin/LJ/Userpic.pm Tue Sep 14 15:34:17 2010 +0800 +++ b/cgi-bin/LJ/Userpic.pm Tue Sep 14 15:42:02 2010 +0800 @@ -87,14 +87,21 @@ sub get { return unless LJ::isu( $u ); return if $u->is_expunged; + my $obj = ref $class ? $class : $class->new( $u, $picid ); my @cache = $class->load_user_userpics( $u ); - if (@cache) { - my $obj = ref $class ? $class : $class->new( $u, $picid ); - foreach my $curr (@cache) { + foreach my $curr ( @cache ) { return $obj->absorb_row( $curr ) if $curr->{picid} == $picid; - } } + + # check the database directly (for expunged userpics, + # which aren't included in load_user_userpics) + 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, $picid ); + return $obj->absorb_row( $row ) if $row; return undef; } --------------------------------------------------------------------------------
no subject
no subject
But yes, I see the humor. :)