#6322: Unable to change action params from beforeFilter()
-----------------------------------+----------------------------------------
Reporter: reuben.helms | Owner:
Type: Bug | Status: reopened
Priority: Medium | Milestone: 1.2.x.x
Component: Routing/Dispatcher | Version: 1.2 Final
Severity: Normal | Resolution:
Keywords: dispatcher | Php_version: PHP 5
Cake_version: 1.2.2.8120 |
-----------------------------------+----------------------------------------
Changes (by reuben.helms):
* status: closed => reopened
* resolution: needmoreinfo =>
Comment:
Whilst changing $this->params in the beforeFilter will change the values
on the controller, those changes never make it to the intended action.
Yes, I am trying to change the value of a passed argument. An example
would be, the user calls
/some_posts/something_else/param:value/param2:value2, as is done in the
test. In the beforeFilter(), I do a calculation, and change on param, and
change it to value3. I would expect the value for param to be 'value3'
when the action is called, but because _invoke() takes a copy of the
params as the second argument, instead of a reference, the original action
is called with the original parameters.
My real world example is that the user called /contents/view/article-
title. In the beforeFilter(), I do a lookup on article-title, and convert
it to an id of an actual content item, and would want to change the params
to reflect the id value, rather than the string "article-title".
Whilst the tests would suggest that the pass value in params is getting
changed to the array 'changed', actual inspection of the pass value before
and after the beforeFilter() call, and even inside the change() action
will reveal that the pass value in $this->params is not getting changed
where it counts.
--
Ticket URL: <https://trac.cakephp.org/ticket/6322#comment:4>
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
-~----------~----~----~----~------~----~------~--~---