News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Topics are not showing up.. but they're there.

Started by DarkTexas, June 19, 2016, 02:07:13 PM

Previous topic - Next topic

margarett

That's really odd.

The total number of topics and boards in BoardIndex is fetched from a field in the "boards" table, while the topic itself is only fetched if the topic (in smf_topics) has a relation to the board through the column id_board.
Because the same database linked to clean files does show the topics, something went sour with your files, I think. Please attach Sources/MessageIndex.php
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

DarkTexas


margarett

It seems that the topics are not fetched anymore after a topic whose first or last poster is a guest.

Try a "clean" MessageIndex.php
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Sir Osis of Liver

Uninstall Avatars on Board and/or MessageIndex mod.

@Bruno - cannot reproduce the problem on a production forum using that file, but code that displays topics has been edited by this mod.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

margarett

Try to have a topic with first or last poster being a guest ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Sir Osis of Liver

Guests can't post on my production forums, and not enough topics on my test installs to duplicate the glitch.  Is it dumping topics with guest posts?

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

margarett

It seems that it only fetches topics until it finds one whose first or last poster is a guest. At least it seems a pattern in DarkTexas's forum:
https://gljclan.com/index.php?board=9.0
Last fetched topic's first (and last :P ) poster is a guest, no more topics are fetched

https://gljclan.com/index.php?board=38.0
Last fetched topic's last poster is a guest, no more topics are fetched

https://gljclan.com/index.php?board=28.0
Last fetched topic's first poster is a guest, no more topics are fetched
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Sir Osis of Liver

Code has been changed here -



/// For search engine effectiveness we'll link guests differently.
$context['pageindex_multiplier'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];

$result = $smcFunc['db_query']('substring', '
SELECT
t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board,
' . ($user_info['is_guest'] ? '0' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from,
IFNULL(avf.id_attach, 0) AS avf_id_attach, avf.filename AS avf_filename, avf.attachment_type AS avf_attachment_type, memf.avatar AS avatar_first_poster,
IFNULL(av.id_attach, 0) AS id_attach, av.filename, av.attachment_type, meml.avatar AS avatar_poster,
t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time,
ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon,
ml.poster_name AS last_member_name, ml.id_member AS last_id_member,
IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg,
mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon,
mf.poster_name AS first_member_name, mf.id_member AS first_id_member,
IFNULL(memf.real_name, mf.poster_name) AS first_display_name, SUBSTRING(ml.body, 1, 385) AS last_body,
SUBSTRING(mf.body, 1, 385) AS first_body, ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}attachments AS av ON (av.id_member = ml.id_member)
LEFT JOIN {db_prefix}attachments AS avf ON (avf.id_member = mf.id_member)
LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)
LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' . ($user_info['is_guest'] ? '' : '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = {int:current_board} AND lmr.id_member = {int:current_member})'). '
WHERE ' . ($pre_query ? 't.id_topic IN ({array_int:topic_list})' : 't.id_board = {int:current_board}') . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
ORDER BY ' . ($pre_query ? 'FIND_IN_SET(t.id_topic, {string:find_set_topics})' : (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC')) . '
LIMIT ' . ($pre_query ? '' : '{int:start}, ') . '{int:maxindex}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'topic_list' => $topic_ids,
'is_approved' => 1,
'find_set_topics' => implode(',', $topic_ids),
'start' => $start,
'maxindex' => $maxindex,
)
);



and here -



/// 'Print' the topic info.
$context['topics'][$row['id_topic']] = array(
'id' => $row['id_topic'],
'first_post' => array(
'id' => $row['id_first_msg'],
'member' => array(
'username' => $row['first_member_name'],
'name' => $row['first_display_name'],
'avatar' => $row['avatar_first_poster'] == '' ? ($row['avf_id_attach'] > 0 ? (empty($row['avf_attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['avf_id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['avf_filename']) : '') : (stristr($row['avatar_first_poster'], 'http://') ? $row['avatar_first_poster'] : $modSettings['avatar_url'] . '/' . $row['avatar_first_poster']),
'id' => $row['first_id_member'],
'href' => !empty($row['first_id_member']) ? $scripturl . '?action=profile;u=' . $row['first_id_member'] : '',
'link' => !empty($row['first_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['first_id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['first_display_name'] . '">' . $row['first_display_name'] . '</a>' : $row['first_display_name']
),
'time' => timeformat($row['first_poster_time']),
'timestamp' => forum_time(true, $row['first_poster_time']),
'subject' => $row['first_subject'],
'preview' => $row['first_body'],
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['first_subject'] . '</a>'
),



But I'm not seeing what's causing the problem.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Also here -



'last_post' => array(
'id' => $row['id_last_msg'],
'member' => array(
'username' => $row['last_member_name'],
'name' => $row['last_display_name'],
'avatar' => $row['avatar_poster'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar_poster'], 'http://') ? $row['avatar_poster'] : $modSettings['avatar_url'] . '/' . $row['avatar_poster']),
'id' => $row['last_id_member'],
'href' => !empty($row['last_id_member']) ? $scripturl . '?action=profile;u=' . $row['last_id_member'] : '',
'link' => !empty($row['last_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['last_id_member'] . '">' . $row['last_display_name'] . '</a>' : $row['last_display_name']
),
'time' => timeformat($row['last_poster_time']),
'timestamp' => forum_time(true, $row['last_poster_time']),
'subject' => $row['last_subject'],
'preview' => $row['last_body'],
'icon' => $row['last_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['id_topic'] . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')),
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')) . '" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'
),


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

DarkTexas

Quote from: Sir Osis of Liver on June 28, 2016, 04:22:04 PM
Uninstall Avatars on Board and/or MessageIndex mod.

@Bruno - cannot reproduce the problem on a production forum using that file, but code that displays topics has been edited by this mod.

That fixed it! OMG!

I love you guys <3

Sir Osis of Liver



I'm guessing it's this -



'first_post' => array(

'avatar' => $row['avatar_first_poster'] == '' ? ($row['avf_id_attach'] > 0 ? (empty($row['avf_attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['avf_id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['avf_filename']) : '') : (stristr($row['avatar_first_poster'], 'http://') ? $row['avatar_first_poster'] : $modSettings['avatar_url'] . '/' . $row['avatar_first_poster']),


'last_post' => array(

'avatar' => $row['avatar_poster'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar_poster'], 'http://') ? $row['avatar_poster'] : $modSettings['avatar_url'] . '/' . $row['avatar_poster']),



Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

DarkTexas


Pipke

The problem here is when fetching the avatars from the topics the mod looks for the user id's of first and last in these topics, when the user id=0 wich is in this example, the mod is first looking for the user id in the members table if not found (ofcourse it will not found , cos there arent any members with id 0) the query is looking for the id in the attachment table in database where the avatars are stored and finds multiple user rows wich contain the id 0 (guest or banned user) , that is where the query get stuck. Hope this explains better the problem.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Advertisement: