[dw-free] Memcache gives off warnings when trying to load a nonexistent style
[commit: http://hg.dwscoalition.org/dw-free/rev/451c8458da72]
http://bugs.dwscoalition.org/show_bug.cgi?id=2089
Fix memcache warnings when you try to use ?s2id=XYZ and XYZ does not exist.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2089
Fix memcache warnings when you try to use ?s2id=XYZ and XYZ does not exist.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/S2.pm
-------------------------------------------------------------------------------- diff -r 5d69dee7c529 -r 451c8458da72 cgi-bin/LJ/S2.pm --- a/cgi-bin/LJ/S2.pm Tue Dec 01 02:03:44 2009 +0000 +++ b/cgi-bin/LJ/S2.pm Tue Dec 01 02:05:48 2009 +0000 @@ -886,6 +886,9 @@ sub create_style my $styleid = $dbh->{'mysql_insertid'}; return 0 unless $styleid; + # in case we had an invalid / empty value from before + LJ::MemCache::delete([$styleid, "s2s:$styleid"]); + return $styleid; } @@ -959,7 +962,7 @@ sub load_style my $memkey = [$id, "s2s:$id"]; my $style = LJ::MemCache::get($memkey); - unless ($style) { + unless ( defined $style ) { $db ||= LJ::S2::get_s2_reader() or die "Unable to get S2 reader"; $style = $db->selectrow_hashref("SELECT styleid, userid, name, modtime ". @@ -967,7 +970,7 @@ sub load_style undef, $id); die $db->errstr if $db->err; - LJ::MemCache::add($memkey, $style, 3600); + LJ::MemCache::add($memkey, $style || {}, 3600); } return undef unless $style; --------------------------------------------------------------------------------