fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-11-08 04:50 am

[dw-free] keyword mapping not showing up in memcache_view.

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

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

Update memcache_view for the new dversion.

Patch by [personal profile] fu.

Files modified:
  • htdocs/admin/memcache_view.bml
--------------------------------------------------------------------------------
diff -r feae888646cf -r 0668b7ae2e57 htdocs/admin/memcache_view.bml
--- a/htdocs/admin/memcache_view.bml	Sat Nov 06 10:09:16 2010 -0500
+++ b/htdocs/admin/memcache_view.bml	Mon Nov 08 12:50:23 2010 +0800
@@ -169,7 +169,7 @@ _c?>
 
      if ($key =~ /^upicinf:(\d+)$/) {
          my $userid = $1;
-         my ($ver, $picstr, $kwstr) = @$val;
+         my ( $ver, $picstr, $kwstr, $picmapstr, $kwmapstr ) = @$val;
          my $info = {
              'version' => $ver,
              'pic' => {},
@@ -193,6 +193,31 @@ _c?>
              $info->{kw}{$kw} = $info->{pic}{$id} if $info;
          }
          $val = $info;
+
+         my $u = LJ::load_userid( $userid );
+         if ( $u->userpic_have_mapid ) {
+             if ( defined $picmapstr && defined $kwmapstr ) {
+                 $pos =  0;
+                 while ($pos < length($picmapstr)) {
+                     my ($mapid, $id, $redir) = unpack("NNN", substr($picmapstr, $pos, 12));
+                     $pos += 12; # 3 * 4 bytes.
+                     $info->{mapid}->{$mapid} = $info->{pic}{$id} if $id;
+                     $info->{map_redir}->{$mapid} = $redir if $redir;
+                 }
+
+                 $pos = $nulpos = 0;
+                 while (($nulpos = index($kwmapstr, "\0", $pos)) > 0) {
+                     my $kw = substr($kwmapstr, $pos, $nulpos-$pos);
+                     my $id = unpack("N", substr($kwmapstr, $nulpos+1, 4));
+                     $pos = $nulpos + 5; # skip NUL + 4 bytes.
+                     $info->{kwmap}->{$kw} = $id;
+                     $info->{mapkw}->{$id} = $kw || "pic#" . $info->{mapid}->{$id}->{picid};
+                 }
+             } else { # This user is on dversion 9, but the data isn't in memcache
+                      # so force a db load
+                 undef $info;
+             }
+         }
      }
 
      if ($key =~ /^friends:/) {
--------------------------------------------------------------------------------

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