From: Evan Prodromou Date: Tue, 13 Oct 2009 21:38:27 +0000 (-0400) Subject: remove inboxes option X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4f5badda94071d9debc8dacfbc9072be3c2ee73d;p=quix0rs-gnu-social.git remove inboxes option --- diff --git a/README b/README index 486656a3bc..037027d431 100644 --- a/README +++ b/README @@ -839,40 +839,8 @@ to update it. Notice inboxes -------------- -Before version 0.6.2, the page showing all notices from people the -user is subscribed to ("so-and-so with friends") was calculated at run -time. Starting with 0.6.2, we have a new data structure for holding a -user's "notice inbox". (Note: distinct from the "message inbox", which -is the "inbox" tab in the UI. The notice inbox appears under the -"Personal" tab.) - -Notices are added to the inbox when they're created. This speeds up -the query considerably, and also allows us the opportunity, in the -future, to add different kind of notices to an inbox -- like @-replies -or subscriptions to search terms or hashtags. - -Notice inboxes are enabled by default for new installations. If you -are upgrading an existing site, this means that your users will see -empty "Personal" pages. The following steps will help you fix the -problem. - -0. $config['inboxes']['enabled'] can be set to one of three values. If - you set it to 'false', the site will work as before. Support for this - will probably be dropped in future versions. -1. Setting the flag to 'transitional' means that you're in transition. - In this mode, the code will run the "new query" or the "old query" - based on whether the user's inbox has been updated. -2. After setting the flag to "transitional", you can run the - fixup_inboxes.php script to create the inboxes. You may want to set - the memory limit high. You can re-run it without ill effect. -3. When fixup_inboxes is finished, you can set the enabled flag to - 'true'. - -NOTE: As of version 0.8.1 notice inboxes are automatically trimmed back - to ~1000 notices every once in a while. - -NOTE: we will drop support for non-inboxed sites in the 0.9.x version -of StatusNet. It's time to switch now! +Notice inboxes are now required. If you don't have inboxes enabled, +StatusNet will no longer run. UTF-8 Database -------------- @@ -1308,9 +1276,8 @@ inboxes For notice inboxes. -enabled: A three-valued flag for whether to use notice inboxes (see - upgrading info above for notes about this change). Can be - 'false', 'true', or '"transitional"'. +enabled: No longer used. If you set this to something other than true, + StatusNet will no longer run. throttle -------- diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index cdb2afb5be..f66e830738 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -99,15 +99,6 @@ class ApiGroupCreateAction extends ApiAuthAction { parent::handle($args); - if (!common_config('inboxes', 'enabled')) { - $this->serverError( - _('Inboxes must be enabled for groups to work'), - 400, - $this->format - ); - return false; - } - if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError( _('This method requires a POST.'), diff --git a/actions/editgroup.php b/actions/editgroup.php index 5dd039f8a3..cf16080356 100644 --- a/actions/editgroup.php +++ b/actions/editgroup.php @@ -64,11 +64,6 @@ class EditgroupAction extends GroupDesignAction { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - if (!common_logged_in()) { $this->clientError(_('You must be logged in to create a group.')); return false; diff --git a/actions/groupbyid.php b/actions/groupbyid.php index 52cfaddfc3..f65bf511af 100644 --- a/actions/groupbyid.php +++ b/actions/groupbyid.php @@ -68,11 +68,6 @@ class GroupbyidAction extends Action { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - $id = $this->arg('id'); if (!$id) { diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php index cd86e3b051..b87b7d156a 100644 --- a/actions/groupdesignsettings.php +++ b/actions/groupdesignsettings.php @@ -64,11 +64,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction { parent::prepare($args); - if (!common_config('inboxes', 'enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - if (!common_logged_in()) { $this->clientError(_('You must be logged in to edit a group.')); return false; diff --git a/actions/grouplogo.php b/actions/grouplogo.php index 63ba769c7a..a9dc7eb1d9 100644 --- a/actions/grouplogo.php +++ b/actions/grouplogo.php @@ -66,11 +66,6 @@ class GrouplogoAction extends GroupDesignAction { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - if (!common_logged_in()) { $this->clientError(_('You must be logged in to create a group.')); return false; diff --git a/actions/grouprss.php b/actions/grouprss.php index 6a6b55e78f..50e48a67e9 100644 --- a/actions/grouprss.php +++ b/actions/grouprss.php @@ -76,11 +76,6 @@ class groupRssAction extends Rss10Action { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); diff --git a/actions/joingroup.php b/actions/joingroup.php index 0209dd43fd..bf69b2ad1e 100644 --- a/actions/joingroup.php +++ b/actions/joingroup.php @@ -56,11 +56,6 @@ class JoingroupAction extends Action { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - if (!common_logged_in()) { $this->clientError(_('You must be logged in to join a group.')); return false; diff --git a/actions/leavegroup.php b/actions/leavegroup.php index 60b22e147d..08fce15098 100644 --- a/actions/leavegroup.php +++ b/actions/leavegroup.php @@ -56,11 +56,6 @@ class LeavegroupAction extends Action { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work.')); - return false; - } - if (!common_logged_in()) { $this->clientError(_('You must be logged in to leave a group.')); return false; diff --git a/actions/newgroup.php b/actions/newgroup.php index a2cf72528b..80da9861a0 100644 --- a/actions/newgroup.php +++ b/actions/newgroup.php @@ -61,11 +61,6 @@ class NewgroupAction extends Action { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - if (!common_logged_in()) { $this->clientError(_('You must be logged in to create a group.')); return false; diff --git a/actions/showgroup.php b/actions/showgroup.php index a67765ce58..bfe45ddad7 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -101,11 +101,6 @@ class ShowgroupAction extends GroupDesignAction { parent::prepare($args); - if (!common_config('inboxes','enabled')) { - $this->serverError(_('Inboxes must be enabled for groups to work')); - return false; - } - $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $nickname_arg = $this->arg('nickname'); diff --git a/classes/Notice.php b/classes/Notice.php index ba2227c0a3..cd3906ca17 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -111,10 +111,9 @@ class Notice extends Memcached_DataObject 'Fave', 'Notice_tag', 'Group_inbox', - 'Queue_item'); - if (common_config('inboxes', 'enabled')) { - $related[] = 'Notice_inbox'; - } + 'Queue_item', + 'Notice_inbox'); + foreach ($related as $cls) { $inst = new $cls(); $inst->notice_id = $this->id; @@ -883,66 +882,61 @@ class Notice extends Memcached_DataObject function addToInboxes() { - $enabled = common_config('inboxes', 'enabled'); + // XXX: loads constants - if ($enabled === true || $enabled === 'transitional') { + $inbox = new Notice_inbox(); - // XXX: loads constants + $users = $this->getSubscribedUsers(); - $inbox = new Notice_inbox(); + // FIXME: kind of ignoring 'transitional'... + // we'll probably stop supporting inboxless mode + // in 0.9.x - $users = $this->getSubscribedUsers(); + $ni = array(); - // FIXME: kind of ignoring 'transitional'... - // we'll probably stop supporting inboxless mode - // in 0.9.x + foreach ($users as $id) { + $ni[$id] = NOTICE_INBOX_SOURCE_SUB; + } - $ni = array(); + $groups = $this->saveGroups(); + foreach ($groups as $group) { + $users = $group->getUserMembers(); foreach ($users as $id) { - $ni[$id] = NOTICE_INBOX_SOURCE_SUB; - } - - $groups = $this->saveGroups(); - - foreach ($groups as $group) { - $users = $group->getUserMembers(); - foreach ($users as $id) { - if (!array_key_exists($id, $ni)) { - $ni[$id] = NOTICE_INBOX_SOURCE_GROUP; - } + if (!array_key_exists($id, $ni)) { + $ni[$id] = NOTICE_INBOX_SOURCE_GROUP; } } + } - $cnt = 0; - - $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES '; - $qry = $qryhdr; + $cnt = 0; - foreach ($ni as $id => $source) { - if ($cnt > 0) { - $qry .= ', '; - } - $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') "; - $cnt++; - if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) { - // FIXME: Causes lag in replicated servers - // Notice_inbox::gc($id); - } - if ($cnt >= MAX_BOXCARS) { - $inbox = new Notice_inbox(); - $inbox->query($qry); - $qry = $qryhdr; - $cnt = 0; - } - } + $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES '; + $qry = $qryhdr; + foreach ($ni as $id => $source) { if ($cnt > 0) { + $qry .= ', '; + } + $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') "; + $cnt++; + if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) { + // FIXME: Causes lag in replicated servers + // Notice_inbox::gc($id); + } + if ($cnt >= MAX_BOXCARS) { $inbox = new Notice_inbox(); $inbox->query($qry); + $qry = $qryhdr; + $cnt = 0; } } + if ($cnt > 0) { + $inbox = new Notice_inbox(); + $inbox->query($qry); + } + return; } @@ -977,11 +971,6 @@ class Notice extends Memcached_DataObject { $groups = array(); - $enabled = common_config('inboxes', 'enabled'); - if ($enabled !== true && $enabled !== 'transitional') { - return $groups; - } - /* extract all !group */ $count = preg_match_all('/(?:^|\s)!([A-Za-z0-9]{1,64})/', strtolower($this->content), diff --git a/classes/User.php b/classes/User.php index 48df0cdd77..0a70c98014 100644 --- a/classes/User.php +++ b/classes/User.php @@ -227,11 +227,9 @@ class User extends Memcached_DataObject } } - $inboxes = common_config('inboxes', 'enabled'); + // This flag is ignored but still set to 1 - if ($inboxes === true || $inboxes == 'transitional') { - $user->inboxed = 1; - } + $user->inboxed = 1; $user->created = common_sql_now(); $user->uri = common_user_uri($user); @@ -433,55 +431,16 @@ class User extends Memcached_DataObject function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) { - $enabled = common_config('inboxes', 'enabled'); - - // Complicated code, depending on whether we support inboxes yet - // XXX: make this go away when inboxes become mandatory - - if ($enabled === false || - ($enabled == 'transitional' && $this->inboxed == 0)) { - $qry = - 'SELECT notice.* ' . - 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . - 'WHERE subscription.subscriber = %d ' . - 'AND notice.is_local != ' . Notice::GATEWAY; - return Notice::getStream(sprintf($qry, $this->id), - 'user:notices_with_friends:' . $this->id, - $offset, $limit, $since_id, $before_id, - $order, $since); - } else if ($enabled === true || - ($enabled == 'transitional' && $this->inboxed == 1)) { - - $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false); + $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false); - return Notice::getStreamByIds($ids); - } + return Notice::getStreamByIds($ids); } function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) { - $enabled = common_config('inboxes', 'enabled'); - - // Complicated code, depending on whether we support inboxes yet - // XXX: make this go away when inboxes become mandatory + $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true); - if ($enabled === false || - ($enabled == 'transitional' && $this->inboxed == 0)) { - $qry = - 'SELECT notice.* ' . - 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . - 'WHERE subscription.subscriber = %d '; - return Notice::getStream(sprintf($qry, $this->id), - 'user:notices_with_friends:' . $this->id, - $offset, $limit, $since_id, $before_id, - $order, $since); - } else if ($enabled === true || - ($enabled == 'transitional' && $this->inboxed == 1)) { - - $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true); - - return Notice::getStreamByIds($ids); - } + return Notice::getStreamByIds($ids); } function blowFavesCache() @@ -752,12 +711,9 @@ class User extends Memcached_DataObject 'Remember_me', 'Foreign_link', 'Invitation', + 'Notice_inbox', ); - if (common_config('inboxes', 'enabled')) { - $related[] = 'Notice_inbox'; - } - foreach ($related as $cls) { $inst = new $cls(); $inst->user_id = $this->id; diff --git a/lib/default.php b/lib/default.php index 329b041e9a..9f3d4b1f9d 100644 --- a/lib/default.php +++ b/lib/default.php @@ -157,7 +157,7 @@ $default = 'ping' => array('notify' => array()), 'inboxes' => - array('enabled' => true), # on by default for new sites + array('enabled' => true), # ignored after 0.9.x 'newuser' => array('default' => null, 'welcome' => null),