From: Shashi Gowda Date: Fri, 8 Jul 2011 06:12:28 +0000 (+0530) Subject: Fix problems in joinAdd with xampp X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=efb7d28d830b1057cc0e57496dcb263955bbb358;p=quix0rs-gnu-social.git Fix problems in joinAdd with xampp Xampp ships with a different version of DB_DataObject PEAR package that cannot do joins using objects correctly. This patch fixes the problem --- diff --git a/classes/Profile_list.php b/classes/Profile_list.php index 2395a369f3..0586a8688c 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -185,10 +185,12 @@ class Profile_list extends Memcached_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_id') + ); + $subs->whereAdd('profile_tag_subscription.profile_tag_id = ' . $this->id); + $subs->selectAdd('unix_timestamp(profile_tag_subscription.' . 'created) as "cursor"'); diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index 9e475e83ec..72dc9c7560 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -55,20 +55,17 @@ class Profile_tag extends Memcached_DataObject return $tags; } - $profile_tag = new Profile_tag(); - $profile_list->tagger = $tagger; - $profile_tag->tagged = $tagged; - - $profile_list->selectAdd(); - - // only fetch id, tag, mainpage and - // private hoping this will be faster - $profile_list->selectAdd('profile_list.id, ' . - 'profile_list.tag, ' . - 'profile_list.mainpage, ' . - 'profile_list.private'); - $profile_list->joinAdd($profile_tag); - $profile_list->find(); + $qry = 'select profile_list.* from profile_list left join '. + 'profile_tag on (profile_list.tag = profile_tag.tag and '. + 'profile_list.tagger = profile_tag.tagger) where '. + 'profile_tag.tagger = %d and profile_tag.tagged = %d '; + $qry = sprintf($qry, $tagger, $tagged); + + if (!$include_priv) { + $qry .= 'profile_list.private = 0'; + } + + $profile_list->query($qry); Profile_list::setCache($key, $profile_list); diff --git a/lib/peopletagnoticestream.php b/lib/peopletagnoticestream.php index 9477ca8ea6..4422261ae9 100644 --- a/lib/peopletagnoticestream.php +++ b/lib/peopletagnoticestream.php @@ -99,7 +99,9 @@ class RawPeopletagNoticeStream extends NoticeStream $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('profile_tag.tagger = ' . $this->profile_list->tagger); + $notice->whereAdd(sprintf('profile_tag.tag = "%s"', $this->profile_list->tag)); if ($since_id != 0) { $notice->whereAdd('notice.id > ' . $since_id);