mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 11:02:40 +00:00
Fixing double merging of url options in paginator helper. This was causing duplicate passed url parameters in next()/prev().
Test cases added. Fixes #391
This commit is contained in:
parent
c64389006d
commit
efa36abdf0
2 changed files with 22 additions and 3 deletions
|
@ -411,12 +411,12 @@ class PaginatorHelper extends AppHelper {
|
|||
${$key} = $options[$key];
|
||||
unset($options[$key]);
|
||||
}
|
||||
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
|
||||
$urlParams = array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step));
|
||||
|
||||
if ($this->{$check}($model)) {
|
||||
return $this->link($title, $url, array_merge($options, array('escape' => $escape, 'class' => $class)));
|
||||
return $this->link($title, $urlParams, array_merge($options, compact('escape', 'class', 'url')));
|
||||
} else {
|
||||
return $this->Html->tag($tag, $title, array_merge($options, array('class' => $class, 'escape' => $escape)));
|
||||
return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class')));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -745,6 +745,25 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'/a',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true,
|
||||
'nextPage' => false, 'pageCount' => 2,
|
||||
'defaults' => array(),
|
||||
'options' => array(
|
||||
'page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array()
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->Paginator->options(array('url' => array(12, 'page' => 3)));
|
||||
$result = $this->Paginator->prev('Prev', array('url' => array(12, 'foo' => 'bar')));
|
||||
$expected = array(
|
||||
'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'),
|
||||
'Prev',
|
||||
'/a',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue