mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix query string parsing on requestAction()
This also fixes a long standing oddity around string URLs that include a query string where the query string data would be duplicated. Refs #9962
This commit is contained in:
parent
7e187a4e41
commit
304117d228
3 changed files with 15 additions and 3 deletions
|
@ -223,7 +223,7 @@ class CakeRequest implements ArrayAccess {
|
|||
unset($query[$unsetUrl]);
|
||||
unset($query[$this->base . $unsetUrl]);
|
||||
if (strpos($this->url, '?') !== false) {
|
||||
list(, $querystr) = explode('?', $this->url);
|
||||
list($this->url, $querystr) = explode('?', $this->url);
|
||||
parse_str($querystr, $queryArgs);
|
||||
$query += $queryArgs;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class RequestActionController extends Controller {
|
|||
* @return string $this->here.
|
||||
*/
|
||||
public function return_here() {
|
||||
return $this->here;
|
||||
return $this->request->here();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,6 +483,17 @@ class ObjectTest extends CakeTestCase {
|
|||
$this->assertNull(Router::getRequest(), 'requests were not popped off the stack, this will break url generation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that here() is calculated correctly in requestAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestActionHere() {
|
||||
$url = '/request_action/return_here?key=value';
|
||||
$result = $this->object->requestAction($url);
|
||||
$this->assertStringEndsWith($url, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test requestAction() and plugins.
|
||||
*
|
||||
|
|
|
@ -193,7 +193,8 @@ class CakeRequestTest extends CakeTestCase {
|
|||
$request = new CakeRequest('some/path?one=something&two=else');
|
||||
$expected = array('one' => 'something', 'two' => 'else');
|
||||
$this->assertEquals($expected, $request->query);
|
||||
$this->assertEquals('some/path?one=something&two=else', $request->url);
|
||||
$this->assertEquals('some/path', $request->url);
|
||||
$this->assertStringEndsWith('/some/path?one=something&two=else', $request->here());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue