Hello!
We recently upgraded our forum from SMF 2.0.10 all the way up to 2.0.14 with patches.
Most things seem to be working fine now. However, I stumbled upon this strange issue with TinyPortal (1.0 - I guess that is outdated, maybe I should upgrade that, too).
We have set up the portal frontpage to show selected articles and selected topics which were promoted to the frontpage.
But strangely, after the upgrade to SMF 2.0.14, only the articles were shown on the frontpage, not the promoted topics anymore. (But the pagination was still divided as if there were missing topics/articles that should be shown.)
So after some fiddling with the code and tracing back where things get lost, and trying and comparing for quite a long time, I found a solution. But I don't know really what it means.
This is a shortened extract from TPortal.php (TinyPortal version 1.0), as it was before I changed it now:
// do the frontpage
function doTPfrontpage()
{
global $context, $scripturl, $user_info, $modSettings, $smcFunc;
// ... a lot of stuff ...
if(count($mposts) > 0)
$request = $smcFunc['db_query']('', '
SELECT m.subject,
' . ($context['TPortal']['frontpage_limit_len'] > 0 ? 'LEFT(m.body,' . $context['TPortal']['frontpage_limit_len'] . ') as body' : 'm.body') . ',
IFNULL(mem.real_name, m.poster_name) AS realName, m.poster_time as date, mem.avatar, mem.posts, mem.date_registered as dateRegistered, mem.last_login as lastLogin,
IFNULL(a.id_attach, 0) AS ID_ATTACH, a.filename, a.attachment_type as attachmentType, t.id_board as category, b.name as category_name,
t.num_replies as numReplies, t.id_topic as id, m.id_member as authorID, t.num_views as views, t.num_replies as replies, t.locked,
IFNULL(thumb.id_attach, 0) AS thumb_id, thumb.filename as thumb_filename
FROM ({db_prefix}topics AS t, {db_prefix}messages AS m)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member AND a.attachment_type != 3)
LEFT JOIN {db_prefix}attachments AS thumb ON (t.id_first_msg = thumb.id_msg AND thumb.attachment_type = 3 AND thumb.fileext IN ("jpg","gif","png") )
LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE t.id_first_msg IN ({array_int:posts})
AND m.id_msg = t.id_first_msg
GROUP BY t.id_first_msg
ORDER BY date DESC, thumb.id_attach ASC',
array('posts' => $mposts)
);
// ... more code ...
// insert the forumposts into $posts
if(is_resource($request) && $smcFunc['db_num_rows']($request) > 0)
{
while($row = $smcFunc['db_fetch_assoc']($request))
{
// do stuff ...
}
// do some more stuff
}
}
The only thing I changed to make it work now was to remove the
is_resource($request) condition from the last if clause. Because it turned out that
is_resource($request) was
false, but the request actually had a lot of results, concerning the selected forum topics for the front page.
I ended up with the idea to remove that condition, because after this there is another database query for fetching the promoted articles, with a similar logic, but without testing for
is_resource($request).
I wonder what this
is_resource($request) actually means. I am not really familiar with PHP. It seems to work fine now without that condition, but certainly there must have been a reason behind it? And after all, it did work all the time with that if-clause on earlier versions of SMF. So I am curious about a technical explanation here.

Looking forward to any hints that you might have.

And of course I'd be interested if my solution is technically okay, or if something could explode at some point now.
