X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fsubs.php;h=3bd67b39c7142ffb64deb1926afa378b4315cfa0;hb=83adf9fa1ab9d288e86fba9907be11454c3e0e28;hp=6fa1dcad3bbba5e07ce01e0a4595c5d11ea4a20e;hpb=2d456a15e5652a0c0e2c0f9f50221eed2d16e109;p=quix0rs-gnu-social.git diff --git a/lib/subs.php b/lib/subs.php index 6fa1dcad3b..3bd67b39c7 100644 --- a/lib/subs.php +++ b/lib/subs.php @@ -1,7 +1,7 @@ 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; }