CakeDC / search

Search Plugin for CakePHP
http://cakedc.com
Other
355 stars 169 forks source link

problem with cakephp 3.1.11 #214

Closed arilia closed 8 years ago

arilia commented 8 years ago

Don't know if this issue is more related to the search plugin or just to cakephp.

Anyhow I just upgraded to 3.1.11 and I noticed this behavior:

I go to my users/index page and I fill one of the inputs to search for users. Let's say I want all users with an "a" in the name field.

I click submit and I am correctly redirected to users/index?name=a url and users are filtered consequently.

but when I change the value (let's say now I want all users having a "b") and press submit I am still redirected to users/index?name=a (and thus seeing users with and "a" in theis names)

It happens with all my Models

I reduced my code to the minimum and it just reflexes the basic examples of the search plugin docs. Of course I have other code in my AppController beforeFilter method but it does not seem to be involved in this problem

I think it has to do with this commit

https://github.com/cakephp/cakephp/commit/82ea081f1f94777fd5c1be4f73ec28dedc82c2dd

It seems that the problem is that cake no more merge the params when generating an url

for now I solved just replacing

$params['?'] = $searchParams;

with

$params = array_merge($params, $searchParams);

in the commonProcess methond

of course is just a patch

andrej-griniuk commented 8 years ago

Hi arilia,

can't reproduce your issue. Could you please let me know how do you render your search form?

arilia commented 8 years ago

my search form is very simple

<?= $this->Form->create(); ?>
<?= $this->Form->input('name'); ?> 
<?= $this->Form->input('family_name'); ?> 
<?= $this->Form->button(__('Find')); ?> 
<?= $this->Form->end()  ?>
<?php debug($users); ?>

and my controller test() method

public function test ()
{
    $this->Prg->commonProcess();
    $this->paginate = [
        'fields' => ['name', 'family_name'],
        'contain' => ['Groups'],
    ];
    $users = $this->Users->find('searchable', $this->Prg->parsedParams());
    $users =  $this->paginate($users);
    $this->set(compact('users'));
}

now I switched to cake 3.2.12 and the issue still remains

cakeDC search should be 2.3.0

andrej-griniuk commented 8 years ago

Fixed and merged.

Megslalk commented 8 years ago

Closing this issue - please re-open or create a new issue should you require further assistance, thanks!