News:

Wondering if this will always be free?  See why free is better.

Main Menu

MessageIndex.php parsing twice possibility

Started by nend, November 25, 2015, 08:25:30 PM

Previous topic - Next topic

nend

In MessageIndex.php if a topic has no replies and preview is enabled the message body is parse twice.

Here is the code section, if the topic has no replies $row['first_body'] and $row['last_body'] will be exactly the same.
            if (!empty($modSettings['preview_characters']))
            {
                // Limit them to $modSettings['preview_characters'] characters
                $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
                if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
                    $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
                $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
                if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
                    $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
                // Censor the subject and message preview.
                censorText($row['first_subject']);
                censorText($row['first_body']);
                // Don't censor them twice!
                if ($row['id_first_msg'] == $row['id_last_msg'])
                {
                    $row['last_subject'] = $row['first_subject'];
                    $row['last_body'] = $row['first_body'];
                }
                else
                {
                    censorText($row['last_subject']);
                    censorText($row['last_body']);
                }
            }

Here is the area where it is done twice in this situation.
                $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
                if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
                    $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
                $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
                if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
                    $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';

I think this
                $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
                if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
                    $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';

Should be moved to the last else in the first code snipplet.
                else
                {
                    censorText($row['last_subject']);
                    censorText($row['last_body']);
                }

Not a real big deal though, but figured it was worth the mention.

*edit I said if a topic has no subject in the top, meant no replies.

nend


Advertisement: