From 4c5098cd32599a2c376beaadb43cd9d471477c90 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 8 Jul 2010 21:17:10 +0000 Subject: Handle the case where a screen name has shifted from one Twitter ID to another --- classes/Foreign_user.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'classes') diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php index 0dd94ffb9..e98a16064 100644 --- a/classes/Foreign_user.php +++ b/classes/Foreign_user.php @@ -39,6 +39,22 @@ class Foreign_user extends Memcached_DataObject return null; } + static function getByNickname($nickname, $service) + { + if (empty($nickname) || empty($service)) { + return null; + } else { + $fuser = new Foreign_user(); + $fuser->service = $service; + $fuser->nickname = $nickname; + $fuser->limit(1); + + $result = $fuser->find(true); + + return empty($result) ? null : $fuser; + } + } + function updateKeys(&$orig) { $this->_connect(); -- cgit v1.2.3-54-g00ecf From dfd65a4290c7c2f6137d5508597189c4202bfaee Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 13 Jul 2010 10:51:25 -0400 Subject: push exception on missing profile down to Notice::getProfile() --- classes/Notice.php | 8 +++++++- lib/apiaction.php | 8 ++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index 482bc550b..ae7e2e540 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -90,7 +90,13 @@ class Notice extends Memcached_DataObject function getProfile() { - return Profile::staticGet('id', $this->profile_id); + $profile = Profile::staticGet('id', $this->profile_id); + + if (empty($profile)) { + throw new ServerException(sprintf(_('No such profile (%d) for notice (%d)'), $this->profile_id, $this->id)); + } + + return $profile; } function delete() diff --git a/lib/apiaction.php b/lib/apiaction.php index 16dd87814..01985f0db 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -462,10 +462,6 @@ class ApiAction extends Action { $profile = $notice->getProfile(); - if (empty($profile)) { - throw new ServerException(sprintf(_('No such profile: %d'), $notice->profile_id)); - } - $entry = array(); // We trim() to avoid extraneous whitespace in the output @@ -798,7 +794,7 @@ class ApiAction extends Action $entry = $this->twitterRssEntryArray($n); $this->showTwitterRssItem($entry); } catch (Exception $e) { - common_log(LOG_ERR, "Error with notice {$n->id}: " . $e->getMessage()); + common_log(LOG_ERR, $e->getMessage()); // continue on exceptions } } @@ -808,7 +804,7 @@ class ApiAction extends Action $entry = $this->twitterRssEntryArray($notice); $this->showTwitterRssItem($entry); } catch (Exception $e) { - common_log(LOG_ERR, "Error with notice {$n->id}: " . $e->getMessage()); + common_log(LOG_ERR, $e->getMessage()); // continue on exceptions } } -- cgit v1.2.3-54-g00ecf From d73feb82d89d66593fd81f8bb5d10b1873fc9458 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 14 Jul 2010 10:38:34 -0400 Subject: cache sitemap notice and user counts for 4h --- classes/Memcached_DataObject.php | 4 ++-- plugins/Sitemap/Sitemap_notice_count.php | 4 +++- plugins/Sitemap/Sitemap_user_count.php | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'classes') diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 4579f64df..a7fec365e 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -593,7 +593,7 @@ class Memcached_DataObject extends Safe_DataObject return $c->get($cacheKey); } - static function cacheSet($keyPart, $value) + static function cacheSet($keyPart, $value, $flag=null, $expiry=null) { $c = self::memcache(); @@ -603,7 +603,7 @@ class Memcached_DataObject extends Safe_DataObject $cacheKey = common_cache_key($keyPart); - return $c->set($cacheKey, $value); + return $c->set($cacheKey, $value, $flag, $expiry); } static function valueString($v) diff --git a/plugins/Sitemap/Sitemap_notice_count.php b/plugins/Sitemap/Sitemap_notice_count.php index 2a375b3e4..6e0061e97 100644 --- a/plugins/Sitemap/Sitemap_notice_count.php +++ b/plugins/Sitemap/Sitemap_notice_count.php @@ -153,7 +153,9 @@ class Sitemap_notice_count extends Memcached_DataObject $noticeCounts[$snc->notice_date] = $snc->notice_count; } - self::cacheSet('sitemap:notice:counts', $noticeCounts); + // Cache notice counts for 4 hours. + + self::cacheSet('sitemap:notice:counts', $noticeCounts, null, time() + 4 * 60 * 60); } return $noticeCounts; diff --git a/plugins/Sitemap/Sitemap_user_count.php b/plugins/Sitemap/Sitemap_user_count.php index 64b4c3442..98dd05bfe 100644 --- a/plugins/Sitemap/Sitemap_user_count.php +++ b/plugins/Sitemap/Sitemap_user_count.php @@ -154,7 +154,9 @@ class Sitemap_user_count extends Memcached_DataObject $userCounts[$suc->registration_date] = $suc->user_count; } - self::cacheSet('sitemap:user:counts', $userCounts); + // Cache user counts for 4 hours. + + self::cacheSet('sitemap:user:counts', $userCounts, null, time() + 4 * 60 * 60); } return $userCounts; -- cgit v1.2.3-54-g00ecf From d51820adc52aef962542ecc6da0607ce0118fefc Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jul 2010 13:43:17 -0700 Subject: Change the cache window on notices from 61 to 200, the max number of notices available at one time through the API. Note: this will require a memcache restart. --- classes/Notice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index ae7e2e540..8552248ba 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -42,10 +42,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -/* We keep the first three 20-notice pages, plus one for pagination check, +/* We keep 200 notices, the max number of notices available per API request, * in the memcached cache. */ -define('NOTICE_CACHE_WINDOW', 61); +define('NOTICE_CACHE_WINDOW', 200); define('MAX_BOXCARS', 128); -- cgit v1.2.3-54-g00ecf From a65b3f171c4d23af8ca844439ad08959eb760b86 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jul 2010 17:38:11 -0700 Subject: Revert "Change the cache window on notices from 61 to 200, the max number" This reverts commit d51820adc52aef962542ecc6da0607ce0118fefc. --- classes/Notice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index 8552248ba..ae7e2e540 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -42,10 +42,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -/* We keep 200 notices, the max number of notices available per API request, +/* We keep the first three 20-notice pages, plus one for pagination check, * in the memcached cache. */ -define('NOTICE_CACHE_WINDOW', 200); +define('NOTICE_CACHE_WINDOW', 61); define('MAX_BOXCARS', 128); -- cgit v1.2.3-54-g00ecf From 9b899eea750fd54c75fbb58e48526a5cab169f6c Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Mon, 19 Jul 2010 21:09:09 -0500 Subject: Make some messages gender neutral. --- actions/all.php | 4 ++-- actions/favor.php | 2 +- actions/finishremotesubscribe.php | 2 +- actions/nudge.php | 2 +- actions/replies.php | 6 +++--- actions/showfavorites.php | 6 +++--- actions/showstream.php | 4 ++-- classes/User.php | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) (limited to 'classes') diff --git a/actions/all.php b/actions/all.php index 9c01b6393..ac4e321d0 100644 --- a/actions/all.php +++ b/actions/all.php @@ -143,10 +143,10 @@ class AllAction extends ProfileAction $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.'); } else { // TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@" - $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); + $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from their profile or [post something to their attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); } } else { - $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname); + $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to their attention.'), $this->user->nickname); } $this->elementStart('div', 'guide'); diff --git a/actions/favor.php b/actions/favor.php index 475912fd0..01976a38f 100644 --- a/actions/favor.php +++ b/actions/favor.php @@ -104,7 +104,7 @@ class FavorAction extends Action } /** - * Notifies a user when his notice is favorited. + * Notifies a user when their notice is favorited. * * @param class $notice favorited notice * @param class $user user declaring a favorite diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index ac51ddec3..0325f6adb 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -37,7 +37,7 @@ require_once INSTALLDIR.'/lib/omb.php'; * Handler for remote subscription finish callback * * When a remote user subscribes a local user, a redirect to this action is - * issued after the remote user authorized his service to subscribe. + * issued after the remote user authorized their service to subscribe. * * @category Action * @package Laconica diff --git a/actions/nudge.php b/actions/nudge.php index cf5f773e7..32ae8587c 100644 --- a/actions/nudge.php +++ b/actions/nudge.php @@ -82,7 +82,7 @@ class NudgeAction extends Action } if (!$other->email || !$other->emailnotifynudge) { - $this->clientError(_('This user doesn\'t allow nudges or hasn\'t confirmed or set his email yet.')); + $this->clientError(_('This user doesn\'t allow nudges or hasn\'t confirmed or set their email yet.')); return; } diff --git a/actions/replies.php b/actions/replies.php index 608f71d6e..0474a6de0 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -196,18 +196,18 @@ class RepliesAction extends OwnerDesignAction function showEmptyListMessage() { - $message = sprintf(_('This is the timeline showing replies to %1$s but %2$s hasn\'t received a notice to his attention yet.'), $this->user->nickname, $this->user->nickname) . ' '; + $message = sprintf(_('This is the timeline showing replies to %1$s but %2$s hasn\'t received a notice to their attention yet.'), $this->user->nickname, $this->user->nickname) . ' '; if (common_logged_in()) { $current_user = common_current_user(); if ($this->user->id === $current_user->id) { $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).'); } else { - $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); + $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) or [post something to their attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); } } else { - $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname); + $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to their attention.'), $this->user->nickname); } $this->elementStart('div', 'guide'); diff --git a/actions/showfavorites.php b/actions/showfavorites.php index 7f3c77ee2..d8042e91c 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -119,7 +119,7 @@ class ShowfavoritesAction extends OwnerDesignAction if (!empty($cur) && $cur->id == $this->user->id) { // Show imported/gateway notices as well as local if - // the user is looking at his own favorites + // the user is looking at their own favorites $this->notice = $this->user->favoriteNotices(true, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); @@ -205,11 +205,11 @@ class ShowfavoritesAction extends OwnerDesignAction if ($this->user->id === $current_user->id) { $message = _('You haven\'t chosen any favorite notices yet. Click the fave button on notices you like to bookmark them for later or shed a spotlight on them.'); } else { - $message = sprintf(_('%s hasn\'t added any notices to his favorites yet. Post something interesting they would add to their favorites :)'), $this->user->nickname); + $message = sprintf(_('%s hasn\'t added any favorite notices yet. Post something interesting they would add to their favorites :)'), $this->user->nickname); } } else { - $message = sprintf(_('%s hasn\'t added any notices to his favorites yet. Why not [register an account](%%%%action.register%%%%) and then post something interesting they would add to their favorites :)'), $this->user->nickname); + $message = sprintf(_('%s hasn\'t added any favorite notices yet. Why not [register an account](%%%%action.register%%%%) and then post something interesting they would add to their favorites :)'), $this->user->nickname); } $this->elementStart('div', 'guide'); diff --git a/actions/showstream.php b/actions/showstream.php index f9407e35a..956c05741 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -204,11 +204,11 @@ class ShowstreamAction extends ProfileAction if ($this->user->id === $current_user->id) { $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)'); } else { - $message .= sprintf(_('You can try to nudge %1$s or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->user->nickname, '@' . $this->user->nickname); + $message .= sprintf(_('You can try to nudge %1$s or [post something to their attention](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->user->nickname, '@' . $this->user->nickname); } } else { - $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname); + $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to their attention.'), $this->user->nickname); } $this->elementStart('div', 'guide'); diff --git a/classes/User.php b/classes/User.php index 2abb7eeb6..cf8d4527b 100644 --- a/classes/User.php +++ b/classes/User.php @@ -524,7 +524,7 @@ class User extends Memcached_DataObject if ($this->id == $other->id) { common_log(LOG_WARNING, sprintf( - "Profile ID %d (%s) tried to block his or herself.", + "Profile ID %d (%s) tried to block themself.", $this->id, $this->nickname ) -- cgit v1.2.3-54-g00ecf From 7065450f03078fb1ac2105b75f9c7a4e052bca9c Mon Sep 17 00:00:00 2001 From: James Walker Date: Tue, 20 Jul 2010 17:34:58 -0700 Subject: normalizing tags for status_network --- classes/Status_network.php | 52 +++++++++++++++++++++++++++++-- classes/Status_network_tag.php | 69 +++++++++++++++++++++++++++++++++++++++++ classes/status_network.ini | 15 +++++++-- db/site.sql | 16 +++++++--- scripts/settag.php | 12 ++----- scripts/setup_status_network.sh | 6 ++-- 6 files changed, 150 insertions(+), 20 deletions(-) create mode 100644 classes/Status_network_tag.php (limited to 'classes') diff --git a/classes/Status_network.php b/classes/Status_network.php index 64016dd79..d1ca454e2 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -27,7 +27,8 @@ class Status_network extends Safe_DataObject /* the code below is auto generated do not remove the above tag */ public $__table = 'status_network'; // table name - public $nickname; // varchar(64) primary_key not_null + public $site_id; // int(4) primary_key not_null + public $nickname; // varchar(64) unique_key not_null public $hostname; // varchar(255) unique_key public $pathname; // varchar(255) unique_key public $dbhost; // varchar(255) @@ -39,7 +40,6 @@ class Status_network extends Safe_DataObject public $logo; // varchar(255) public $created; // datetime() not_null public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP - public $tags; // text /* Static get */ function staticGet($k,$v=NULL) { @@ -308,9 +308,55 @@ class Status_network extends Safe_DataObject */ function getTags() { - return array_filter(explode("|", strval($this->tags))); + $result = array(); + + $tags = new Status_network_tag(); + $tags->site_id = $this->site_id; + if ($tags->find()) { + while ($tags->fetch()) { + $result[] = $tags->tag; + } + } + + return $result; } + /** + * Save a given set of tags + * @param array tags + */ + function setTags($tags) + { + $this->clearTags(); + foreach ($tags as $tag) { + $snt = new Status_network_tag(); + $snt->site_id = $this->site_id; + $snt->tag = $tag; + $snt->created = common_sql_now(); + + $id = $snt->insert(); + if (!$id) { + throw new Exception(_("Unable to save tag.")); + } + } + + return true; + } + + function clearTags() + { + $tag = new Status_network_tag(); + $tag->site_id = $this->site_id; + + if ($tag->find()) { + while($tag->fetch()) { + $tag->delete(); + } + } + + $tag->free(); + } + /** * Check if this site record has a particular meta-info tag attached. * @param string $tag diff --git a/classes/Status_network_tag.php b/classes/Status_network_tag.php new file mode 100644 index 000000000..18c508bc8 --- /dev/null +++ b/classes/Status_network_tag.php @@ -0,0 +1,69 @@ +. + */ + +if (!defined('STATUSNET')) { exit(1); } + +class Status_network_tag extends Safe_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + public $__table = 'status_network_tag'; // table name + public $site_id; // int(4) primary_key not_null + public $tag; // varchar(64) primary_key not_null + public $created; // datetime() not_null + + + function __construct() + { + global $config; + global $_DB_DATAOBJECT; + + $sn = new Status_network(); + $sn->_connect(); + + $config['db']['table_'. $this->__table] = $sn->_database; + + $this->_connect(); + } + + + /* Static get */ + function staticGet($k,$v=null) + { + $i = DB_DataObject::staticGet('Status_network_tag',$k,$v); + + // Don't use local process cache; if we're fetching multiple + // times it's because we're reloading it in a long-running + // process; we need a fresh copy! + global $_DB_DATAOBJECT; + unset($_DB_DATAOBJECT['CACHE']['status_network_tag']); + return $i; + } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE + + + + function pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('Status_network_tag', $kv); + } +} diff --git a/classes/status_network.ini b/classes/status_network.ini index adb71cba7..83226e915 100644 --- a/classes/status_network.ini +++ b/classes/status_network.ini @@ -1,4 +1,5 @@ [status_network] +side_id = 129 nickname = 130 hostname = 2 pathname = 2 @@ -11,9 +12,19 @@ theme = 2 logo = 2 created = 142 modified = 384 -tags = 34 [status_network__keys] -nickname = K +site_id = K +nickname = U hostname = U pathname = U + +[status_network_tag] +site_id = 129 +tag = 130 +created = 142 + +[status_network_tag__keys] +site_id = K +tag = K + diff --git a/db/site.sql b/db/site.sql index 791303bd5..bc425841d 100644 --- a/db/site.sql +++ b/db/site.sql @@ -1,8 +1,9 @@ /* For managing multiple sites */ create table status_network ( - - nickname varchar(64) primary key comment 'nickname', + + site_id integer auto_increment primary key comment 'unique id', + nickname varchar(64) unique key comment 'nickname', hostname varchar(255) unique key comment 'alternate hostname if any', pathname varchar(255) unique key comment 'alternate pathname if any', @@ -15,9 +16,16 @@ create table status_network ( theme varchar(255) comment 'theme name', logo varchar(255) comment 'site logo', - tags text comment 'site meta-info tags (pipe-separated)', - created datetime not null comment 'date this record was created', modified timestamp comment 'date this record was modified' ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci; + +create table status_network_tag ( + site_id integer comment 'unique id', + tag varchar(64) comment 'tag name', + created datetime not null comment 'date the record was created', + + constraint primary key (site_id, tag) +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci; + diff --git a/scripts/settag.php b/scripts/settag.php index d1b06ff10..ca260f7bf 100644 --- a/scripts/settag.php +++ b/scripts/settag.php @@ -39,11 +39,10 @@ if (count($args) < 1) { } $nickname = $args[0]; - $sn = Status_network::memGet('nickname', $nickname); if (empty($sn)) { - print "No such site.\n"; + print "No such site ($nickname).\n"; exit(-1); } @@ -54,16 +53,13 @@ if (count($args) == 1) { exit(0); } $tag = $args[1]; - $i = array_search($tag, $tags); if ($i !== false) { if (have_option('d', 'delete')) { // Delete unset($tags[$i]); - $orig = clone($sn); - $sn->tags = implode('|', $tags); - $result = $sn->update($orig); + $result = $sn->setTags($tags); if (!$result) { print "Couldn't update.\n"; exit(-1); @@ -78,9 +74,7 @@ if ($i !== false) { exit(-1); } else { $tags[] = $tag; - $orig = clone($sn); - $sn->tags = implode('|', $tags); - $result = $sn->update($orig); + $result = $sn->setTags($tags); if (!$result) { print "Couldn't update.\n"; exit(-1); diff --git a/scripts/setup_status_network.sh b/scripts/setup_status_network.sh index 4ebb696c7..3dd739030 100755 --- a/scripts/setup_status_network.sh +++ b/scripts/setup_status_network.sh @@ -44,8 +44,8 @@ mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS GRANT ALL ON $database.* TO '$username'@'localhost' IDENTIFIED BY '$password'; GRANT ALL ON $database.* TO '$username'@'%' IDENTIFIED BY '$password'; -INSERT INTO status_network (nickname, dbhost, dbuser, dbpass, dbname, sitename, created, tags) -VALUES ('$nickname', '$DBHOSTNAME', '$username', '$password', '$database', '$sitename', now(), '$tags'); +INSERT INTO status_network (nickname, dbhost, dbuser, dbpass, dbname, sitename, created) +VALUES ('$nickname', '$DBHOSTNAME', '$username', '$password', '$database', '$sitename', now()); ENDOFCOMMANDS @@ -56,6 +56,8 @@ done php $PHPBASE/scripts/checkschema.php -s"$server" +php $PHPBASE/scripts/settag.php -s"$server" "$nickname" "$tags" + php $PHPBASE/scripts/registeruser.php \ -s"$server" \ -n"$nickname" \ -- cgit v1.2.3-54-g00ecf From 25e963769c866d6847064fd88172483a9c6b1964 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 21 Jul 2010 12:29:47 -0700 Subject: Revert "Revert "Change the cache window on notices from 61 to 200, the max number"" This reverts commit a65b3f171c4d23af8ca844439ad08959eb760b86. --- classes/Notice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Notice.php b/classes/Notice.php index ae7e2e540..8552248ba 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -42,10 +42,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -/* We keep the first three 20-notice pages, plus one for pagination check, +/* We keep 200 notices, the max number of notices available per API request, * in the memcached cache. */ -define('NOTICE_CACHE_WINDOW', 61); +define('NOTICE_CACHE_WINDOW', 200); define('MAX_BOXCARS', 128); -- cgit v1.2.3-54-g00ecf From 29b8a6a18f67de74fb6adb9e91c10e7d1577c067 Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 28 Jul 2010 11:57:54 -0400 Subject: don't try to save empty tags --- classes/Status_network.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'classes') diff --git a/classes/Status_network.php b/classes/Status_network.php index d1ca454e2..339f4c813 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -329,14 +329,16 @@ class Status_network extends Safe_DataObject { $this->clearTags(); foreach ($tags as $tag) { - $snt = new Status_network_tag(); - $snt->site_id = $this->site_id; - $snt->tag = $tag; - $snt->created = common_sql_now(); - - $id = $snt->insert(); - if (!$id) { - throw new Exception(_("Unable to save tag.")); + if (!empty($tag)) { + $snt = new Status_network_tag(); + $snt->site_id = $this->site_id; + $snt->tag = $tag; + $snt->created = common_sql_now(); + + $id = $snt->insert(); + if (!$id) { + throw new Exception(_("Unable to save tag.")); + } } } -- cgit v1.2.3-54-g00ecf From 5688c635a62ea109a9aa9565e40e994ea984cd95 Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 28 Jul 2010 12:13:53 -0400 Subject: backwards compatibility for old tags format in hasTag --- classes/Status_network.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'classes') diff --git a/classes/Status_network.php b/classes/Status_network.php index 339f4c813..a0f3ba5f7 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -318,6 +318,11 @@ class Status_network extends Safe_DataObject } } + // XXX : for backwards compatibility + if (empty($result)) { + return explode('|', $this->tags); + } + return $result; } -- cgit v1.2.3-54-g00ecf