]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
don't write Inbox if on a read-only page, but encache
authorEvan Prodromou <evan@status.net>
Thu, 14 Jan 2010 00:26:46 +0000 (16:26 -0800)
committerEvan Prodromou <evan@status.net>
Thu, 14 Jan 2010 00:28:42 +0000 (16:28 -0800)
classes/Inbox.php
index.php

index e14d4f4e7eddbb3c2821877d02d61896274e49ce..83cfe8ef827fa735512fe7389c05d0b3f798a378 100644 (file)
@@ -56,6 +56,22 @@ class Inbox extends Memcached_DataObject
      */
 
     static function initialize($user_id)
      */
 
     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();
 
     {
         $ids = array();
 
@@ -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));
 
         $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;
     }
 
         return $inbox;
     }
@@ -95,7 +105,7 @@ class Inbox extends Memcached_DataObject
     {
         $inbox = Inbox::staticGet('user_id', $user_id);
 
     {
         $inbox = Inbox::staticGet('user_id', $user_id);
 
-        if (empty($inbox)) {
+        if (empty($inbox) || $inbox->fake) {
             $inbox = Inbox::initialize($user_id);
         }
 
             $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::staticGet('user_id', $user_id);
 
         if (empty($inbox)) {
-            $inbox = Inbox::initialize($user_id);
+            $inbox = Inbox::fromNoticeInbox($user_id);
             if (empty($inbox)) {
                 return array();
             if (empty($inbox)) {
                 return array();
+            } else {
+                $inbox->encache();
             }
         }
 
             }
         }
 
index 59805f60009f94a0f973f11e1ee324b3af9b1cb7..b5edc0f947b4e2c0ddb9d1e92a282e64db8db00d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -150,7 +150,7 @@ function checkMirror($action_obj, $args)
 {
     global $config;
 
 {
     global $config;
 
-    static $alwaysRW = array('session', 'remember_me', 'inbox');
+    static $alwaysRW = array('session', 'remember_me');
 
     if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) {
         if (is_array(common_config('db', 'mirror'))) {
 
     if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) {
         if (is_array(common_config('db', 'mirror'))) {