diff options
author | Evan Prodromou <evan@status.net> | 2010-01-10 12:31:43 -0800 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-01-10 12:31:43 -0800 |
commit | 9d3893255a77ee6c6cf1ab861d0da55ecbadbecc (patch) | |
tree | ea8c379e3d927d172a69ed0c4e1d32fc8d8f7abe | |
parent | 30409f7bad45862ce498d7084ab2a8a4287e7d3f (diff) |
don't put Users with object IDs in the cache, and don't fetch them
-rw-r--r-- | classes/Memcached_DataObject.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index ca360d411..21f6781c2 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -68,7 +68,7 @@ class Memcached_DataObject extends DB_DataObject // Clear this out so we don't accidentally break global // state in *this* process. $this->_DB_resultid = null; - + // We don't have any local DBO refs, so clear these out. $this->_link_loaded = false; } @@ -171,7 +171,16 @@ class Memcached_DataObject extends DB_DataObject if (!$c) { return false; } else { - return $c->get(Memcached_DataObject::cacheKey($cls, $k, $v)); + $obj = $c->get(Memcached_DataObject::cacheKey($cls, $k, $v)); + if (0 == strcasecmp($cls, 'User')) { + // Special case for User + if (is_object($obj->id)) { + common_log(LOG_ERR, "User " . $obj->nickname . " was cached with User as ID; deleting"); + $c->delete(Memcached_DataObject::cacheKey($cls, $k, $v)); + return false; + } + } + return $obj; } } @@ -190,6 +199,12 @@ class Memcached_DataObject extends DB_DataObject $c = $this->memcache(); if (!$c) { return false; + } else if ($this->tableName() == 'user' && is_object($this->id)) { + // Special case for User bug + $e = new Exception(); + common_log(LOG_ERR, __METHOD__ . ' caching user with User object as ID ' . + str_replace("\n", " ", $e->getTraceAsString())); + return false; } else { $pkey = array(); $pval = array(); |