MrJuliuss / syntara

Admin package for Laravel 4.
MIT License
302 stars 77 forks source link

User search appends rows in users list #139

Closed samarulrajt closed 10 years ago

samarulrajt commented 10 years ago

Hi Juliuss,

First of all i thank you for a wonderful script. I am facing a problem in my site . while we do a search from the users list. I get the following error http://gyazo.com/06d26609348ee617d2d0c9eee267b6f4.

to check this you can login to

http://laravel.tech-armada.net/dashboard username : sam@tech-armada.net password : 12345678

it appends a row again. when we do all searches in the users list. but it is not happening in my localhost. So please do reply regarding this issue.

Thanks

Sam

MrJuliuss commented 10 years ago

Hello,

wow very strange...i will watch it ;)

Julien

samarulrajt commented 10 years ago

Thanks for quick reply! Tell me the ways to fix this.

Sam

MrJuliuss commented 10 years ago

Can you verify if you're only one user with id 1 in your production database ?

MrJuliuss commented 10 years ago

Can you replace this line (if it's okay i will fix it in the repository) in your project vendor (just for the test) : https://github.com/MrJuliuss/syntara/blob/master/src/controllers/UserController.php#L63

with : if(isset($bannedUsers) && $bannedUsers !== "" && bannedUsers !== "--")

(I can't reproduce on my own server or computer, but i think it will fix the problem)

samarulrajt commented 10 years ago

Thanks Juliuss,

I reproduced as you said from this if(isset($bannedUsers) && $bannedUsers !== "") to if(isset($bannedUsers) && $bannedUsers !== "" && bannedUsers !== "--")

and it works fine.

Thanks ,

Sam

MrJuliuss commented 10 years ago

Hi, i will fix it in a release asap (the fix i gave you is not very proper, it's just for the test)

Julien

samarulrajt commented 10 years ago

But still i get the same this when we search with banned as No. all other things with searches are ok

http://gyazo.com/6f02ae8362155c1142b1f223c96722b0

Thanks

Sam

MrJuliuss commented 10 years ago

Hmm, add this juste before the query in UserController (https://github.com/MrJuliuss/syntara/blob/master/src/controllers/UserController.php#L63)

if($bannedUsers == '0')
{
$bannedUsers = (int)$bannedUsers;
}

not easy to debug when you can reproduce the bug =/

samarulrajt commented 10 years ago

Still that banned search as No not works if($bannedUsers == '0') { $bannedUsers = (int)$bannedUsers; } if(isset($bannedUsers) && $bannedUsers !== "" && $bannedUsers !== "--") {

        $emptyUsers = $emptyUsers->join('throttle', 'throttle.user_id', '=', 'users.id')
            ->where('throttle.banned', '=', $bannedUsers)
            ->select('users.id', 'users.username', 'users.last_name', 'users.first_name', 'users.email', 'users.permissions', 'users.activated');
    }

but it still not works . http://gyazo.com/6f02ae8362155c1142b1f223c96722b0

Thanks

Sam

MrJuliuss commented 10 years ago

Hm...which database ? which engine ?

samarulrajt commented 10 years ago

mysql database and InnoDB engine

MrJuliuss commented 10 years ago

Could you launch this request in your production server :

select `users`.`id`, `users`.`username`, `users`.`last_name`, `users`.`first_name`, `users`.`email`, `users`.`permissions`, `users`.`activated`
from `users`
inner join `throttle` on `throttle`.`user_id` = `users`.`id`
where `throttle`.`banned` = 0

And tell me if you have a duplicate user in the result.

samarulrajt commented 10 years ago

i get the result as http://gyazo.com/5ae2c1a0fc0f30a3a5e3b3165c89fe43

samarulrajt commented 10 years ago

Hi Juliuss

I solved it via throttle where i had same userid dublicated for each ip address so i removed dublicated userid from throttle and that solved my problem. i really don't know the use of this throttle table.

but still that throttle

http://gyazo.com/b4b1ba17a83bf6cb6206a5b39b6e9055

makes problem

Thanks

Sam

MrJuliuss commented 10 years ago

Oh ! The solution : add a DISTINCT in the request... :)

samarulrajt commented 10 years ago

i solved it with this

$emptyUsers = $emptyUsers->join('throttle', 'throttle.user_id', '=', 'users.id') ->where('throttle.banned', '=', $bannedUsers) ->select('users.id', 'users.username', 'users.last_name', 'users.first_name', 'users.email', 'users.permissions', 'users.activated') ->distinct();

when we use this there is another problem exists that is when user is banned he is not listed in users list anyway i will fix it

thanks

Sam

MrJuliuss commented 10 years ago

Yeah, there is a problem with the "--" passed in the url. I'm watching it.

samarulrajt commented 10 years ago

okey Thanks

MrJuliuss commented 10 years ago

Fix : https://github.com/MrJuliuss/syntara/commit/19a5a5415e819e7dfceef5fc9a331365dc47b2f3

I will release it soon.

Julien

samarulrajt commented 10 years ago

I will update my files

Thanks

Sam