mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
commit
5e0dc218f1
2 changed files with 33 additions and 1 deletions
|
@ -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.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue