From b83af83b82a9719e946504866058770b109ece71 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Aug 2011 11:37:45 -0400 Subject: [PATCH 1/5] return links for foreign keys --- classes/Managed_DataObject.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/Managed_DataObject.php b/classes/Managed_DataObject.php index 7263b3e320..552d980fba 100644 --- a/classes/Managed_DataObject.php +++ b/classes/Managed_DataObject.php @@ -152,4 +152,18 @@ abstract class Managed_DataObject extends Memcached_DataObject return $style; } + + function links() + { + $links = array(); + + $table = call_user_func(array(get_class($this), 'schemaDef')); + + foreach ($table['foreign keys'] as $keyname => $keydef) { + if (count($keydef) == 2 && is_string($keydef[0]) && is_array($keydef[1]) && count($keydef[1]) == 1) { + $links[$keydef[1][0]] = $keydef[0].':'.$keydef[1][1]; + } + } + return $links; + } } \ No newline at end of file From 04dccad3bb4bce38b53b02ce1e8847e621bad495 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Aug 2011 11:38:05 -0400 Subject: [PATCH 2/5] Activity notices on by default --- lib/default.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/default.php b/lib/default.php index 9c4c8cab05..71b2257cd5 100644 --- a/lib/default.php +++ b/lib/default.php @@ -310,7 +310,8 @@ $default = 'TagSub' => null, 'OpenID' => null, 'Directory' => null, - 'ExtendedProfile' => null), + 'ExtendedProfile' => null, + 'Activity' => null), 'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories 'server' => null, 'sslserver' => null, From f251c2e03656d62349a5996a358862f7076d477a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Aug 2011 11:38:39 -0400 Subject: [PATCH 3/5] Explicit joins for people tags --- lib/peopletagnoticestream.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/peopletagnoticestream.php b/lib/peopletagnoticestream.php index 9477ca8ea6..e82d754e8d 100644 --- a/lib/peopletagnoticestream.php +++ b/lib/peopletagnoticestream.php @@ -96,10 +96,10 @@ class RawPeopletagNoticeStream extends NoticeStream $notice->selectAdd(); $notice->selectAdd('notice.id'); - $ptag = new Profile_tag(); - $ptag->tag = $this->profile_list->tag; - $ptag->tagger = $this->profile_list->tagger; - $notice->joinAdd($ptag); + $notice->joinAdd(array('profile_id', 'profile_tag:tagged')); + + $notice->whereAdd(sprintf('profile_tag.tag = "%s"', $this->profile_list->tag)); + $notice->whereAdd(sprintf('profile_tag.tagger = %d', $this->profile_list->tagger)); if ($since_id != 0) { $notice->whereAdd('notice.id > ' . $since_id); From a47c372ac4a14d3919161334e4bffe9063e5ed32 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Aug 2011 11:39:06 -0400 Subject: [PATCH 4/5] explicit join for subscribers to a profile list --- classes/Profile_list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/Profile_list.php b/classes/Profile_list.php index 50aa71f55d..c433a53fee 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -220,10 +220,9 @@ class Profile_list extends Managed_DataObject function getSubscribers($offset=0, $limit=null, $since=0, $upto=0) { $subs = new Profile(); - $sub = new Profile_tag_subscription(); - $sub->profile_tag_id = $this->id; - $subs->joinAdd($sub); + $subs->joinAdd(array('id', 'profile_tag_subscription:profile_tag_id')); + $subs->selectAdd('unix_timestamp(profile_tag_subscription.' . 'created) as "cursor"'); From 34a0525b672280eff763e827adc67134b847b131 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Aug 2011 11:48:40 -0400 Subject: [PATCH 5/5] Profile uses joinAdd() with explicit arguments --- classes/Profile.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/Profile.php b/classes/Profile.php index bcbb406ae0..228a0ae202 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -435,6 +435,7 @@ class Profile extends Managed_DataObject $tags->tagged = $this->id; $lists->joinAdd($tags); + #@fixme: postgres (round(date_part('epoch', my_date))) $lists->selectAdd('unix_timestamp(profile_tag.modified) as "cursor"'); @@ -507,7 +508,8 @@ class Profile extends Managed_DataObject $lists = new Profile_list(); $subs = new Profile_tag_subscription(); - $lists->joinAdd($subs); + $lists->joinAdd('id', 'profile_tag_subscription:profile_tag_id'); + #@fixme: postgres (round(date_part('epoch', my_date))) $lists->selectAdd('unix_timestamp(profile_tag_subscription.created) as "cursor"');