[livejournal] r19046: LJSUP-8805 (Log stacktrace of LJ::MemCac...
Committer: ailyin
LJSUP-8805 (Log stacktrace of LJ::MemCache error)U trunk/cgi-bin/LJ/MemCache.pm
Modified: trunk/cgi-bin/LJ/MemCache.pm
===================================================================
--- trunk/cgi-bin/LJ/MemCache.pm 2011-05-12 06:45:15 UTC (rev 19045)
+++ trunk/cgi-bin/LJ/MemCache.pm 2011-05-12 07:01:27 UTC (rev 19046)
@@ -158,6 +158,7 @@
use String::CRC32 qw();
use Carp qw();
+use Data::Dumper qw();
use IO::Handle qw();
### VARIABLES ###
@@ -631,10 +632,40 @@
return unless $format_info;
my $format_version = $format_info->[0];
- return unless $array
- and ref $array eq "ARRAY"
- and $array->[0] == $format_version;
+ return unless defined $array;
+
+ unless ($array) {
+ Carp::cluck "trying to unserialize $format from memcache, "
+ . Data::Dumper::Dumper($array) . " is not a true value; "
+ . "stacktrace follows";
+ return;
+ }
+
+ unless ( ref $array eq 'ARRAY' ) {
+ Carp::cluck "trying to unserialize $format from memcache, "
+ . Data::Dumper::Dumper($array) . " is not an array value; "
+ . "stacktrace follows";
+ return;
+ }
+
+ unless ( @$array ) {
+ Carp::cluck "trying to unserialize $format from memcache, "
+ . Data::Dumper::Dumper($array) . " is an empty arrayref; "
+ . "stacktrace follows";
+ return;
+ }
+
+ unless ( $array->[0] =~ /^\d+$/ ) {
+ Carp::cluck "trying to unserialize $format from memcache, "
+ . Data::Dumper::Dumper($array) . " has a non-numeric "
+ . "'$array->[0]' as its version string; "
+ . "stacktrace follows";
+ return;
+ }
+
+ return unless $array->[0] == $format_version;
+
my %ret;
foreach my $i ( 1 .. $#$format_info ) {
$ret{ $format_info->[$i] } = $array->[$i];
