SMF 2.0.2 searching users by date broken -- patch

Started by anpaza, March 08, 2012, 06:50:51 AM

Previous topic - Next topic

anpaza

Hello!

I have found a small bug in the user management code.
If you go to Admin -> Users -> Search Users and set a criteria like "Last post < 2012-01-01" and then press Enter, the first page of results will be fine. But if you have more than one page of results, and you click on the second page link, for example, the search criteria will be dropped and you'll suddenly find that the number of pages substantially changed.

This is caused by the fact that $_POST['last_post'] is checked against the 'valid date' regexp, an then is converted to seconds-since-1970 format. Upon a repeated invocation the seconds-since-1970 formatted date doesn't pass the check and thus is dropped from the SQL search condition.

The attached patch fixes this by letting the seconds-since-1970 be a valid date format.


emanuele

Hello anpaza,

thanks for the report and the fix!

FYI: this should be fixed in the development branch.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

anpaza

Ah, there's a bugtracker :)
Next time will look there first  :D

anpaza

By the way, today found that the same happens if you delete such users after searching.
I had 8 pages of bogus user accounts (0 messages and last login earlier than one year ago).
I have selected the whole 1st page and pressed "Delete users".
After deletion there were 18 pages of users, e.g. the whole database.
So, the search criteria is dropped after deletion of users.
Has this been fixed?

emanuele

Unfortunately at the moment I cannot check because I don't have a big enough database to test.

If you want to try, the attached file should be the patch with the changes I made (hope it applies to a clean 2.0.2, but I'm not 100% sure...).


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

anpaza

The patch did not applied cleanly, but I managed to apply it manually (btw, what software/options did you use to create it? Looked a bit unusual).

I think the manual patch worked, since the bug with going to second page of a user search works fine now. However, if I check any of those users and delete them, the filter is dropped.

You can check it easily by registering a bogus account, then doing some search that would find it (e.g. register date > 2011-01-01), then checking the just created account and deleting it. After deletion you will be presented with a full userlist.

emanuele

Quote from: anpaza on March 10, 2012, 02:27:58 AM
The patch did not applied cleanly, but I managed to apply it manually (btw, what software/options did you use to create it? Looked a bit unusual).
It comes from kdesvn...

Quote from: anpaza on March 10, 2012, 02:27:58 AM
I think the manual patch worked, since the bug with going to second page of a user search works fine now. However, if I check any of those users and delete them, the filter is dropped.
Debugged a bit and got it.

Code (find) Select
if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST))
Code (replace with) Select
if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types']))
Of course $_POST can contain something different that the search types!!!

It seems to work, if you can confirm I'll apply it. ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

anpaza

Indeed, applied and worked!
Thank you very much, with my near-zero PHP knowledge I would have to spend a whole day hunting it! :)

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: