summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2010-01-14 01:50:21 +0000
committerSarven Capadisli <csarven@status.net>2010-01-14 01:50:21 +0000
commit085406ea88efd4caaad3933871554dd30a23eba6 (patch)
tree78828e20ad893a84060090395b06e365e7123467 /classes
parentacc48289e5f87e879e6a1182b43e405016e675d6 (diff)
parentfba840ed568222b082dbac81cd8e38217d53a7ec (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'classes')
-rw-r--r--classes/Inbox.php30
1 files changed, 21 insertions, 9 deletions
diff --git a/classes/Inbox.php b/classes/Inbox.php
index e14d4f4e7..83cfe8ef8 100644
--- a/classes/Inbox.php
+++ b/classes/Inbox.php
@@ -57,6 +57,22 @@ class Inbox extends Memcached_DataObject
static function initialize($user_id)
{
+ $inbox = Inbox::fromNoticeInbox($user_id);
+
+ unset($inbox->fake);
+
+ $result = $inbox->insert();
+
+ if (!$result) {
+ common_log_db_error($inbox, 'INSERT', __FILE__);
+ return null;
+ }
+
+ return $inbox;
+ }
+
+ static function fromNoticeInbox($user_id)
+ {
$ids = array();
$ni = new Notice_inbox();
@@ -80,13 +96,7 @@ class Inbox extends Memcached_DataObject
$inbox->user_id = $user_id;
$inbox->notice_ids = call_user_func_array('pack', array_merge(array('N*'), $ids));
-
- $result = $inbox->insert();
-
- if (!$result) {
- common_log_db_error($inbox, 'INSERT', __FILE__);
- return null;
- }
+ $inbox->fake = true;
return $inbox;
}
@@ -95,7 +105,7 @@ class Inbox extends Memcached_DataObject
{
$inbox = Inbox::staticGet('user_id', $user_id);
- if (empty($inbox)) {
+ if (empty($inbox) || $inbox->fake) {
$inbox = Inbox::initialize($user_id);
}
@@ -133,9 +143,11 @@ class Inbox extends Memcached_DataObject
$inbox = Inbox::staticGet('user_id', $user_id);
if (empty($inbox)) {
- $inbox = Inbox::initialize($user_id);
+ $inbox = Inbox::fromNoticeInbox($user_id);
if (empty($inbox)) {
return array();
+ } else {
+ $inbox->encache();
}
}