diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-01-23 08:43:34 +0000 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-01-23 08:43:34 +0000 |
commit | 1305ecf4bd58b8651fd8648d65263a24ed47bbc6 (patch) | |
tree | f4437adc6e405e1c3e1118c8f7e38d5802d0f55a /lib/subs.php | |
parent | 76cf3cc3d0046e1d94c8a7dcb7c2fff21e145ee5 (diff) | |
parent | be21ed13b5160646cc4feb7c572d878bc0ee464d (diff) |
Merge branch 'master' of /var/www/trunk
Diffstat (limited to 'lib/subs.php')
-rw-r--r-- | lib/subs.php | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/subs.php b/lib/subs.php index 6fa1dcad3..0e7b9ded5 100644 --- a/lib/subs.php +++ b/lib/subs.php @@ -60,23 +60,22 @@ function subs_subscribe_to($user, $other) subs_notify($other, $user); - if (common_config('memcached', 'enabled')) { - $cache = new Memcache(); - if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) { - $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); - } - } + $cache = common_memcache(); + + if ($cache) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); + } + if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) { if (!$other->subscribeTo($user)) { return _('Could not subscribe other to you.'); } - if (common_config('memcached', 'enabled')) { - $cache = new Memcache(); - if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) { - $cache->delete(common_cache_key('user:notices_with_friends:' . $other->id)); - } - } + $cache = common_memcache(); + + if ($cache) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $other->id)); + } subs_notify($user, $other); } @@ -134,12 +133,11 @@ function subs_unsubscribe_to($user, $other) if (!$sub->delete()) return _('Couldn\'t delete subscription.'); - if (common_config('memcached', 'enabled')) { - $cache = new Memcache(); - if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) { - $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); - } - } + $cache = common_memcache(); + + if ($cache) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); + } return true; } |