Merge pull request #9488 from tersmitten/lastaction-should-also-work-with-named-parameters-in-the-url-2x

_lastAction() should also work with named parameters in the url
This commit is contained in:
Mark Story 2016-09-24 21:04:14 -04:00 committed by GitHub
commit 5e0dc218f1
2 changed files with 33 additions and 1 deletions

View file

@ -10648,4 +10648,36 @@ class FormHelperTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* Tests `_lastAction`.
*
* With named, numeric value
*
* @return void
*/
public function testLastActionWithNamedNumeric() {
$here = '/users/index/page:1';
$this->Form->request->here = $here;
$this->Form->create('User');
$this->assertAttributeEquals($here, '_lastAction', $this->Form, "_lastAction shouldn't be empty.");
}
/**
* Tests `_lastAction`.
*
* With named, string value
*
* @return void
*/
public function testLastActionWithNamedString() {
$here = '/users/index/foo:bar';
$this->Form->request->here = $here;
$this->Form->create('User');
$this->assertAttributeEquals($here, '_lastAction', $this->Form, "_lastAction shouldn't be empty.");
}
}

View file

@ -3107,7 +3107,7 @@ class FormHelper extends AppHelper {
* @return void
*/
protected function _lastAction($url) {
$action = html_entity_decode($this->url($url), ENT_QUOTES);
$action = html_entity_decode($this->url($url, true), ENT_QUOTES);
$query = parse_url($action, PHP_URL_QUERY);
$query = $query ? '?' . $query : '';
$this->_lastAction = parse_url($action, PHP_URL_PATH) . $query;