MyBB Community Forums

Full Version: syndication.php missing title and link on reply posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
What's the exact query string in the URL you're entering? syndication.php doesn't tell us anything.

But if I understood correctly, your posts (replies) in syndication don't display titles/links? That's weird because MyBB queries (or at least should query) only threads and their first posts by default, not replies.
Actually, no parameters, just http://.../syndication.php

But the default http://.../syndication.php?limit=15
behaves the same way.

Yes, if the 'fid' parameter is in the url, it only shows the first post of each thread, which I'm not sure why that would be desirable.

Showing replies in syndication is actually a good thing for me.  I want to be able to easily monitor new posts across all the forums without all the drilling down, and fortunately this does that for me.  

Yes, I possibly could have made it more clear if I had posted what you see as a user but thought the xml would be more helpful to the programmer. i.e.

... - All Forums
...
about apples
today
apples are red or green

today
bananas are yellow

As you can see the "RE: about bananas" title and link is missing.
please clarify whether you have modified syndication.php file to get post replies. if so, provide that modified file here (attach / link)
(2015-07-20, 05:41 AM).m. Wrote: [ -> ]please clarify whether you have modified syndication.php file to get post replies. if so, provide that modified file here (attach / link)

With default installation, no modifications, and no parameters, syndication.php does show post replies.
^ please have a look at syndication page of this community => http://community.mybb.com/syndication.php
I found the problem.

Some how, the firstpost field in the threads table is off by 1 for 3 records in a row, so querying the posts table for pid IN (implode(',',$firstpost)) was getting some wrong numbers.

Now to find where that could have happened.  I think I may have accidentally created the problem editing the threads table earlier.

I have corrected the firstpost numbers in my threads table and now syndication works as you expect. Sorry for the red herring.

Consider this closed.