vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r17097: LJSUP-6521: check the possibility deseri...

Committer: vsukhanov
LJSUP-6521: check the possibility deserialization previously cached S1 style data
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2010-08-09 05:20:58 UTC (rev 17096)
+++ trunk/cgi-bin/LJ/User.pm	2010-08-09 06:09:27 UTC (rev 17097)
@@ -9087,6 +9087,15 @@
     my $s1uc_memkey = [$u->{'userid'}, "s1uc:$u->{'userid'}"];
     if ($u->{'useoverrides'} eq "Y" || $u->{'themeid'} == 0) {
         $s1uc = LJ::MemCache::get($s1uc_memkey);
+
+        ## validate integrity memcached data
+        if ($s1uc->{'override_stor'}  
+            and not eval { Storable::thaw($s1uc->{'override_stor'}); 1 }
+        ){
+            ## recache data if it's not deserializable.
+            $s1uc = undef;
+        }
+
         unless ($s1uc) {
             my $db;
             my $setmem = 1;
@@ -9098,6 +9107,14 @@
             }
             $s1uc = $db->selectrow_hashref("SELECT * FROM s1usercache WHERE userid=?",
                                            undef, $u->{'userid'});
+            
+            ## validate integrity of the data that has been cached in mysql
+            if ($s1uc->{'override_stor'} 
+                and not eval { Storable::thaw($s1uc->{'override_stor'}); 1 }
+            ){
+                ## recache data if it's not deserializable.
+                $s1uc = undef;
+            }
             LJ::MemCache::set($s1uc_memkey, $s1uc) if $s1uc && $setmem;
         }
     }

Tags: livejournal, pm, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments