diff options
author | sarven <csarven@plantard.controlezvous.ca> | 2009-01-23 08:52:24 +0000 |
---|---|---|
committer | sarven <csarven@plantard.controlezvous.ca> | 2009-01-23 08:52:24 +0000 |
commit | 0aa2cb35f19fa52160331e9a3846fc9a37a8bc98 (patch) | |
tree | 1612445f9c7657f8800191be46312e0ed4e1a5aa /lib/subs.php | |
parent | 6c9bbdb56174f106ceeebab9a4b6f0ee452ee17f (diff) | |
parent | 9c5ab86d0e9fd318eaa3767651975d85a9ffce1a (diff) |
Merge branch 'master' of ../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; } |