MyBB Community Forums

Full Version: wrong chronological order at multiquote
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have just been faced with a multiquote problem I don't know how to solve.

I check different posts on different pages of a thread for a multiquote. Looking at the post preview, the different quotes are shown in a wrong chronological order.

I do not have any plugin running, that might have an impact on quoting posts.

I tried to reproduce this behaviour at the german support forum and at mybb.com as well. However, it seems that the problem exists only at my website.....Sad

I run version 1.6.7, with the latest PHP 5.3.13 and MySQL server 5.5.

Any help or hint how to solve this problem is very much appreciated.

Thank you.

StefanT indicated that the problem might be due to a missing ORDER BY statement.

So I changed the following lines of xmlhttp.php
	// Query for any posts in the list which are not within the specified thread
	$query = $db->query("
		SELECT p.subject, p.message, p.pid, p.tid, p.username, p.dateline, t.fid, p.visible, u.username AS userusername
		FROM ".TABLE_PREFIX."posts p
		LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
		WHERE {$from_tid}p.pid IN ($quoted_posts) {$unviewable_forums}
	");
into
	// Query for any posts in the list which are not within the specified thread
	$query = $db->query("
		SELECT p.subject, p.message, p.pid, p.tid, p.username, p.dateline, t.fid, p.visible, u.username AS userusername
		FROM ".TABLE_PREFIX."posts p
		LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
		WHERE {$from_tid}p.pid IN ($quoted_posts) {$unviewable_forums}
        ORDER BY p.dateline
	");

The following lines of newreply.php
			require_once MYBB_ROOT."inc/functions_posting.php";
			$query = $db->query("
				SELECT p.subject, p.message, p.pid, p.tid, p.username, p.dateline, u.username AS userusername
				FROM ".TABLE_PREFIX."posts p
				LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
				WHERE p.pid IN ($quoted_posts) {$unviewable_forums} {$visible_where}
			");
have to be changed into
			require_once MYBB_ROOT."inc/functions_posting.php";
			$query = $db->query("
				SELECT p.subject, p.message, p.pid, p.tid, p.username, p.dateline, u.username AS userusername
				FROM ".TABLE_PREFIX."posts p
				LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
				WHERE p.pid IN ($quoted_posts) {$unviewable_forums} {$visible_where}
                ORDER BY p.dateline
			");

It seems that this solved my problem. At least so far.... Wink
check your posts table in phpmyadmin to see what the indexes are. if not indexed on PID then your order can be by the record order in the database (which may be our of order due to optimization, etc)
Hi pavemen,

Thank you for your answer. Indexes of the posts table are shown in the attachment. Seems that pid is not included. I have never changed structure elements of the tables and optimizing tables is done on regular base. Huh
this may or may not be by design. there does not need to be indexed on PID and it may not be there by default. i can't remember if I added it myself or not.