summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/deletenotice.php3
-rw-r--r--classes/Notice.php34
2 files changed, 22 insertions, 15 deletions
diff --git a/actions/deletenotice.php b/actions/deletenotice.php
index 0db7e0d1e..64746283a 100644
--- a/actions/deletenotice.php
+++ b/actions/deletenotice.php
@@ -84,6 +84,9 @@ class DeletenoticeAction extends DeleteAction {
$replies->get('notice_id', $notice_id);
common_dequeue_notice($notice);
+ if (common_config('memcached', 'enabled')) {
+ $notice->blowSubsCache();
+ }
$replies->delete();
$notice->delete();
} else {
diff --git a/classes/Notice.php b/classes/Notice.php
index 7c7580615..2d880f8cb 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -116,23 +116,27 @@ class Notice extends DB_DataObject
# XXX: someone clever could prepend instead of clearing the cache
if (common_config('memcached', 'enabled')) {
- $cache = new Memcache();
- if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
- $user = new User();
-
- $user->query('SELECT id ' .
- 'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
- 'WHERE subscription.subscribed = ' . $notice->profile_id);
-
- while ($user->fetch()) {
- $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
- }
-
- $user->free();
- unset($user);
- }
+ $notice->blowSubsCache();
}
return $notice;
}
+
+ function blowSubsCache() {
+ $cache = new Memcache();
+ if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
+ $user = new User();
+
+ $user->query('SELECT id ' .
+ 'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
+ 'WHERE subscription.subscribed = ' . $this->profile_id);
+
+ while ($user->fetch()) {
+ $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
+ }
+
+ $user->free();
+ unset($user);
+ }
+ }
}