We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 4d7cdbf1 authored by Evan Prodromou's avatar Evan Prodromou

don't write Inbox if on a read-only page, but encache

parent 935d5eed
......@@ -56,6 +56,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();
......@@ -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();
}
}
......
......@@ -150,7 +150,7 @@ function checkMirror($action_obj, $args)
{
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'))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment