#5603: Paginate: Passed action parameters are not filtered properly
-------------------------------+--------------------------------------------
Reporter: geiru | Type: Bug
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: General
Version: RC3 | Severity: Normal
Keywords: | Php_version: n/a
Cake_version: 1.2.0.7692 RC3 |
-------------------------------+--------------------------------------------
== What I did: ==
Paginate data in an controller action that accepts parameters passed to
it. Create a link with the paginator helper that contains the passed
arguments.
Source code controller:
{{{
class ExampleController extends AppController {
...
function listing($param1, $param2)
{
$this->paginate('ModelName');
}
...
}
}}}
Source code view:
{{{
$paginator->options(array('url'=>$paginator->params['pass']));
echo $paginator->link('first page',array('page' => 1));
}}}
== What I expected to happen: ==
If the called action would be listing/p1/p2 I expected the paginator-
helper link method to create a link 'listing/p1/p2/page:1'.
== Why it didn't meet my expectations ==
The link created was 'listing/p1/p1/p2/page:1'
The problem is, that the paginate function in controller.php does not
properly filter the passed arguments. The resulting params array in the
helper contains a field params[paging][default_model][options][0] which
has the value of the first passed parameter.
== Possible Fix: ==
The problem is the in_array - function used in
cake/libs/controller/controller.php line 959 (Revision: 7689, Thu Oct 02
04:16:09 CEST, gwoo).
{{{
if (!in_array($keys[$i], $vars)) {
}}}
This line should be changed to:
{{{
if (!in_array($keys[$i], $vars,true)) {
}}}
The reason for this is that the first passed parameter has the key 0 in
the $options-array. If in_array is called without the last parameter being
true, it doesn't check the type of the needle and detects any string as
integer 0 if the needle is an integer.
If you try:
{{{
var_dump(in_array(0,array('string1','string2','string3')));
var_dump(in_array(0,array('string1','string2','string3'),true));
}}}
the first line gives you 'true' and the second line gives you the correct
'false'.
--
Ticket URL: <https://trac.cakephp.org/ticket/5603>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---