MyBB Community Forums

Full Version: [F] search finduserthreads problem with limit [C-StefanT]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
From profile there are 2 options.
1. Find All Threads
2. Find All Posts

If you have limit set for search results.

If you Find All Posts the results display the newest posts first.

BUG: If you Find All Threads the results display the oldest threads first and cut off the new threads because of order.

If no limit is set then the search results do indeed display newest threads first. So this is related to limit.

You can see example from HF on my own profile.

Possible fix:

search.php

if(intval($mybb->settings['searchhardlimit']) > 0)
{
	$limitsql = "LIMIT ".intval($mybb->settings['searchhardlimit']);
}

Change to:

if(intval($mybb->settings['searchhardlimit']) > 0)
{
	$limitsql = "ORDER BY dateline DESC LIMIT ".intval($mybb->settings['searchhardlimit']);
}

Please confirm my fix but I looked as good as I can for any possible side effect problems.
Fix should be:

if(intval($mybb->settings['searchhardlimit']) > 0)
{
    $limitsql = "ORDER BY t.dateline DESC LIMIT ".intval($mybb->settings['searchhardlimit']);
} 
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group
Ahh...I will commit my fix then but as just dateline it was working fine.

Isn't t.dateline an issue if the search is by p.dateline? Just asking but I haven't looked over the code or tried your fix yet.
The $limitsql variable you refer to only applies to the thread query. There is a separate $limitsql query for posts in inc/functions_search.php

The reason dateline worked without the prefix is because MySQL is noob-proof and automatically renames it to t.dateline if there is only one row with that name. But it always better to be more specific, especially if you intend on continuing to develop your product. Who knows when the day comes that you will turn a single query to a join query.
Thanks for explaning and for fixing.