Bug #531

Findguest/user search error

Added by Tom Moore about 2 years ago. Updated about 2 years ago.

Status:Closed Start date:11/12/2009
Priority:Normal Due date:
Assignee:Tom Moore % Done:

100%

Category:Search
Target version:1.4.10
Reproducibility:Always Database Type:MySQL
Reported In MyBB Version:1.6.0 Database Version:
PHP Version:5.3.0 SQA assignments:
Browser:

Description

This is a very strange bug, so I'll do my best to explain it.

In the current 1.6, the finding guest/user posts query options are set like so:

$options = array(
    'limit' => intval($mybb->settings['searchhardlimit']),
    'order_by' => 'dateline',
    'order_dir' => 'desc',
);

If the searchhardlimit is set to 0 (disabled), then the query always returns 0 results. In 1.4, the query options are like this:

$options = array(
    'LIMIT' => intval($mybb->settings['searchhardlimit']),
    'order_by' => 'dateline',
    'order_dir' => 'DESC'
);

The capitalisation of the limit seems to make the query skip the fact the searchhardlimit setting is 0. If, for instance, you change it to lowercase (to standards, I guess), the query recognises this and returns 0 results. This isn't so much a bug in 1.4, as it works either way (if there is or isn't a setting).

A possible fix:

$options = array(
    'order_by' => 'dateline',
    'order_dir' => 'desc'
);

// Do we have a hard search limit?
$mybb->settings['searchhardlimit'] = intval($mybb->settings['searchhardlimit']);
if($mybb->settings['searchhardlimit'] > 0)
{
    $options['limit'] = $mybb->settings['searchhardlimit'];
}

An other option is to simply capitalise the limit in the 1.6 query options array and it will work as it does in 1.4.

So, which fix should I apply? And should I apply it to 1.4 too? I'd rather fix both to the above code...

Associated revisions

Revision 4505
Added by Tom Moore about 2 years ago

Fixes Findguest/user search error (fixes: 531)

History

Updated by Ryan Gordon about 2 years ago

Actually, that was a bug in MyBB 1.4. Those options should all be lower case. I thought I fixed that already???

Having a capitalized "LIMIT" makes it ignore that array key all together as it only looks for "limit". It is doing its job correctly by having a "limit of 0", we just need to run an if, to ignore the limit setting all together if the hard limit is indeed 0.

Updated by Tom Moore about 2 years ago

You fixed a different part - same problem though. In 1.4, the sections have LIMIT. In 1.6, they have limit, but if searchhardlimit is 0, then the results are 0.

The two sections that are affected here are the finduser and findguest actions of search.php.

Should I change 1.4 to lower case limit, and add in the if statement?

Updated by Ryan Gordon about 2 years ago

Yeah that sounds good. You're fix can just be this:

@$options = array(
'order_by' => 'dateline',
'order_dir' => 'desc'
);

// Do we have a hard search limit?
if($mybb->settings['searchhardlimit'] > 0) {
$options['limit'] = intval($mybb->settings['searchhardlimit']);
}@

Updated by Tom Moore about 2 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4505.

Updated by Ryan Gordon about 2 years ago

  • Target version set to 1.4.10

Updated by Michael Schlechtinger about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF