Since I was impatient, I have made my own adaptation to MyBB 1.4.6 as follows.
The following is a unified context diff of syndication.php, so the lines that were removed from the distributed version are marked with a leading - and the lines inserted instead are marked with a leading + sign.
I have chosen to revert to a select with JOIN, but at least, instead of joining 4 tables as with the previous version, I am only joining two tables.
Since the syndication of replies is only desirable in lower-traffic boards, the performance penalty should not be too bad. I think I would not need the items array altogether now, but I didn't want to deviate from the current code more than necessary.
Both subject and dateline are taken from the post instead of the thread, this will usually make replies discernable by the leading "RE:".
The link is formed leading to the individual post.
The following is a unified context diff of syndication.php, so the lines that were removed from the distributed version are marked with a leading - and the lines inserted instead are marked with a leading + sign.
I have chosen to revert to a select with JOIN, but at least, instead of joining 4 tables as with the previous version, I am only joining two tables.
Since the syndication of replies is only desirable in lower-traffic boards, the performance penalty should not be too bad. I think I would not need the items array altogether now, but I didn't want to deviate from the current code more than necessary.
Both subject and dateline are taken from the post instead of the thread, this will usually make replies discernable by the leading "RE:".
The link is formed leading to the individual post.
diff -u -r1.1 syndication.php
--- syndication.php 2009/05/24 21:33:27 1.1
+++ syndication.php 2009/05/25 23:08:10
@@ -111,40 +111,35 @@
);
$feedgenerator->set_channel($channel);
-// Get the threads to syndicate.
-$query = $db->simple_select("threads", "subject, tid, dateline, firstpost",
-"visible='1' AND closed NOT LIKE 'moved|%' ".$forumlist,
-array('order_by' => 'dateline', 'order_dir' => 'DESC', 'limit' => $thread_limit));
-// Loop through all the threads.
-while($thread = $db->fetch_array($query))
+// Get the posts to syndicate.
+$query = $db->query("
+ SELECT p.subject, t.tid, p.pid, p.dateline, p.edittime, p.message,
+ p.fid FROM ".TABLE_PREFIX."posts p
+ LEFT JOIN ".TABLE_PREFIX."threads t ON (p.tid=t.tid)
+ WHERE t.visible='1' AND t.closed NOT LIKE 'moved|%' ".$forumlist."
+ ORDER BY p.dateline DESC LIMIT 0,".$thread_limit);
+// Loop through all the posts.
+while($post = $db->fetch_array($query))
{
- $items[$thread['tid']] = array(
- "title" => $thread['subject'],
- "link" => $channel['link'].get_thread_link($thread['tid']),
- "date" => $thread['dateline'],
+ $items[$post['pid']] = array(
+ "title" => $post['subject'],
+ "link" => $channel['link'].get_post_link($post['pid'],$post['tid'])."#pid".$post['pid'],
+ "date" => $post['dateline'],
);
- $firstposts[] = $thread['firstpost'];
-}
-
-if(!empty($firstposts))
-{
- $firstpostlist = "pid IN(".$db->escape_string(implode(',', $firstposts)).")";
- $query = $db->simple_select("posts", "message, edittime, tid, fid",
- $firstpostlist, array('order_by' => 'dateline', 'order_dir' => 'desc'));
- while($post = $db->fetch_array($query))
- {
$parser_options = array(
"allow_html" => $forumcache[$post['fid']]['allowhtml'],
"allow_mycode" => $forumcache[$post['fid']]
...
- $items[$post['tid']]['description'] = $parser->parse_message($post['message'], $parser_options);
- $items[$post['tid']]['updated'] = $post['edittime'];
- $feedgenerator->add_item($items[$post['tid']]);
- }
+ $items[$post['pid']]['description'] = $parser->parse_message($post['message'], $parser_options);
+ $items[$post['pid']]['updated'] = $post['edittime'];
+ $feedgenerator->add_item($items[$post['pid']]);
}