2015-07-19, 09:24 PM
MyBB Version 1.8.5
Description: I was looking at the output of syndication.php on my site and saw:
<generator>MyBB</generator>
<item>
<title><![CDATA[about apples]]></title>
<link>http://.../showthread.php?tid=1</link>
<pubDate>...</pubDate>
<guid isPermaLink="false">http://.../showthread.php?tid=1</guid>
<description><![CDATA[apples are red or green]]></description>
<content:encoded><![CDATA[apples are red or green]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link></link>
<pubDate>...</pubDate>
<guid isPermaLink="false"></guid>
<description><![CDATA[bananas are yellow]]></description>
<content:encoded><![CDATA[bananas are yellow]]></content:encoded>
</item>
...
Problem:
- The <title>, <link> and <guid> fields in the second post about bananas are empty.
- Note: The post about bananas is a reply to an about bananas thread, not to the first thread about apples.
Poking through the code, I have fixed it with almost certainly the wrong code, but here goes. Starting on line 228 of syndication.php, (about 4 or 5 lines up from the bottom of the file) before the $feedgenerator->add_item($items[$post['tid']]); line I inserted:
$items[$post['tid']]['title'] = $parser->parse_badwords($post['subject']);
if( !$items[$post['tid']]['link'] ) {
$items[$post['tid']]['link'] = $channel['link'].get_post_link($post['pid'] . "#pid" . $post['pid'], $post['tid']);
}
The call to get_post_link() is a bit ugly because post urls seem to require the #pid{pid} part to work correctly as a clickable link, which is not contained in the THREAD_URL_POST constant in init.php. If I add it there, it adds two of those #pid{pid} parts to the post urls display in the show thread.php, so someone more familiar with the base code will have to make some decisions.
Now the results are correct as shown below
<generator>MyBB</generator>
<item>
<title><![CDATA[about apples]]></title>
<link>http://.../showthread.php?tid=1</link>
<pubDate>...</pubDate>
<guid isPermaLink="false">http://.../showthread.php?tid=1</guid>
<description><![CDATA[apples are red or green]]></description>
<content:encoded><![CDATA[apples are red or green]]></content:encoded>
</item>
<item>
<title><![CDATA[RE: about bananas]]></title>
<link>http://.../showthread.php?tid=2&pid=4#pid4</link>
<pubDate>...</pubDate>
<guid isPermaLink="false">http://.../showthread.php?tid=2&pid=4#pid4</guid>
<description><![CDATA[bananas are yellow]]></description>
<content:encoded><![CDATA[bananas are yellow]]></content:encoded>
</item>
...
Hope that helps.
Update: Problem was induced by me dinking with the firstpost field in the threads table earlier that day. Rookie mistake.
Description: I was looking at the output of syndication.php on my site and saw:
<generator>MyBB</generator>
<item>
<title><![CDATA[about apples]]></title>
<link>http://.../showthread.php?tid=1</link>
<pubDate>...</pubDate>
<guid isPermaLink="false">http://.../showthread.php?tid=1</guid>
<description><![CDATA[apples are red or green]]></description>
<content:encoded><![CDATA[apples are red or green]]></content:encoded>
</item>
<item>
<title><![CDATA[]]></title>
<link></link>
<pubDate>...</pubDate>
<guid isPermaLink="false"></guid>
<description><![CDATA[bananas are yellow]]></description>
<content:encoded><![CDATA[bananas are yellow]]></content:encoded>
</item>
...
Problem:
- The <title>, <link> and <guid> fields in the second post about bananas are empty.
- Note: The post about bananas is a reply to an about bananas thread, not to the first thread about apples.
Poking through the code, I have fixed it with almost certainly the wrong code, but here goes. Starting on line 228 of syndication.php, (about 4 or 5 lines up from the bottom of the file) before the $feedgenerator->add_item($items[$post['tid']]); line I inserted:
$items[$post['tid']]['title'] = $parser->parse_badwords($post['subject']);
if( !$items[$post['tid']]['link'] ) {
$items[$post['tid']]['link'] = $channel['link'].get_post_link($post['pid'] . "#pid" . $post['pid'], $post['tid']);
}
The call to get_post_link() is a bit ugly because post urls seem to require the #pid{pid} part to work correctly as a clickable link, which is not contained in the THREAD_URL_POST constant in init.php. If I add it there, it adds two of those #pid{pid} parts to the post urls display in the show thread.php, so someone more familiar with the base code will have to make some decisions.
Now the results are correct as shown below
<generator>MyBB</generator>
<item>
<title><![CDATA[about apples]]></title>
<link>http://.../showthread.php?tid=1</link>
<pubDate>...</pubDate>
<guid isPermaLink="false">http://.../showthread.php?tid=1</guid>
<description><![CDATA[apples are red or green]]></description>
<content:encoded><![CDATA[apples are red or green]]></content:encoded>
</item>
<item>
<title><![CDATA[RE: about bananas]]></title>
<link>http://.../showthread.php?tid=2&pid=4#pid4</link>
<pubDate>...</pubDate>
<guid isPermaLink="false">http://.../showthread.php?tid=2&pid=4#pid4</guid>
<description><![CDATA[bananas are yellow]]></description>
<content:encoded><![CDATA[bananas are yellow]]></content:encoded>
</item>
...
Hope that helps.
Update: Problem was induced by me dinking with the firstpost field in the threads table earlier that day. Rookie mistake.