From ea8653f9470ceb09a4d5ddca2aec023f2f7fe5a2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 16 Jun 2010 08:39:09 -0700 Subject: Fix for ticket #1131. If the rss feed is for an item, then retrieve the item. Using the left and right pointers find all the comments for the child items. Thanks to jankoprowski for the initial investigation. --- modules/comment/helpers/comment_rss.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules/comment/helpers/comment_rss.php') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index eee6f750..a18beb9b 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -33,13 +33,20 @@ class comment_rss_Core { return; } + Kohana_Log::add("error", "feed($feed_id, $offset, $limit, $id)"); $comments = ORM::factory("comment") ->viewable() ->where("state", "=", "published") ->order_by("created", "DESC"); if ($feed_id == "item") { - $comments->where("item_id", "=", $id); + $item = ORM::factory("item", $id); + $subquery = db::select("id") + ->from("items") + ->where("left_ptr", ">=", $item->left_ptr) + ->where("right_ptr", "<=", $item->right_ptr); + $comments + ->where("item_id", "in", $subquery); } $feed = new stdClass(); -- cgit v1.2.3 From 8ee60e6b5d694a8117c94595a0f03090cd41cca8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 16 Jun 2010 11:17:18 -0700 Subject: slap my wrist... i forgot a debugging statement --- modules/comment/helpers/comment_rss.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules/comment/helpers/comment_rss.php') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index a18beb9b..479023bd 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -33,7 +33,6 @@ class comment_rss_Core { return; } - Kohana_Log::add("error", "feed($feed_id, $offset, $limit, $id)"); $comments = ORM::factory("comment") ->viewable() ->where("state", "=", "published") -- cgit v1.2.3 From 75002732284c85dfd82934b04ef477fc5a274bfe Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 10:55:10 -0700 Subject: Simplify the descendent logic. viewable() already joins with the items table so there's no need for a subquery. The subquery could generate way too many ids since it didn't pay attention to permissions. This isn't a security problem since we were restricting the item ids according to permissions in the outer query, but it's wasteful. --- modules/comment/helpers/comment_rss.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'modules/comment/helpers/comment_rss.php') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 479023bd..2e8e564e 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -35,17 +35,14 @@ class comment_rss_Core { $comments = ORM::factory("comment") ->viewable() - ->where("state", "=", "published") - ->order_by("created", "DESC"); + ->where("comments.state", "=", "published") + ->order_by("comments.created", "DESC"); if ($feed_id == "item") { $item = ORM::factory("item", $id); - $subquery = db::select("id") - ->from("items") - ->where("left_ptr", ">=", $item->left_ptr) - ->where("right_ptr", "<=", $item->right_ptr); $comments - ->where("item_id", "in", $subquery); + ->where("items.left_ptr", ">=", $item->left_ptr) + ->where("items.right_ptr", "<=", $item->right_ptr); } $feed = new stdClass(); @@ -65,6 +62,8 @@ class comment_rss_Core { ArrayObject::ARRAY_AS_PROPS); } + Kohana_Log::add("error",print_r(Database::instance()->last_query(),1)); + $feed->max_pages = ceil($comments->count_all() / $limit); $feed->title = htmlspecialchars(t("Recent Comments")); $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id)); -- cgit v1.2.3 From 7938a57dbe1935731dccc945235b10bf5c002dd2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 10:57:48 -0700 Subject: Oops. Remove debug line. --- modules/comment/helpers/comment_rss.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules/comment/helpers/comment_rss.php') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 2e8e564e..545192e5 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -62,8 +62,6 @@ class comment_rss_Core { ArrayObject::ARRAY_AS_PROPS); } - Kohana_Log::add("error",print_r(Database::instance()->last_query(),1)); - $feed->max_pages = ceil($comments->count_all() / $limit); $feed->title = htmlspecialchars(t("Recent Comments")); $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id)); -- cgit v1.2.3 From 74e821b03ef149a43eb8704fd2350985699d3ded Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 17:21:25 -0700 Subject: Rename the feed variable from "children" to "comments" since that makes more semantic sense. --- modules/comment/helpers/comment_rss.php | 4 ++-- modules/comment/views/comment.mrss.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'modules/comment/helpers/comment_rss.php') diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 545192e5..26d98d21 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -47,10 +47,10 @@ class comment_rss_Core { $feed = new stdClass(); $feed->view = "comment.mrss"; - $feed->children = array(); + $feed->comments = array(); foreach ($comments->find_all($limit, $offset) as $comment) { $item = $comment->item(); - $feed->children[] = new ArrayObject( + $feed->comments[] = new ArrayObject( array("pub_date" => date("D, d M Y H:i:s T", $comment->created), "text" => nl2br(html::purify($comment->text)), "thumb_url" => $item->thumb_url(), diff --git a/modules/comment/views/comment.mrss.php b/modules/comment/views/comment.mrss.php index c2a4b538..809e7890 100644 --- a/modules/comment/views/comment.mrss.php +++ b/modules/comment/views/comment.mrss.php @@ -20,19 +20,19 @@ - children as $child): ?> + comments as $comment): ?> - <?= html::purify($child->title) ?> - item_uri) ?> - author) ?> - item_uri ?> - pub_date ?> + <?= html::purify($comment->title) ?> + item_uri) ?> + author) ?> + item_uri ?> + pub_date ?> text)) ?>

+

text)) ?>

- +

]]> -- cgit v1.2.3