FIX: Redirect loop with multiple URL tokens (fixes #8607)

This commit is contained in:
Loz Calver 2018-11-15 11:15:31 +00:00
parent 598edd9134
commit 86701b8cd0
2 changed files with 10 additions and 7 deletions

View File

@ -123,9 +123,10 @@ class ConfirmationTokenChain
* @return array
*/
public function getRedirectUrlParams() {
$params = array();
$params = $_GET;
unset($params['url']);
foreach ($this->filteredTokens() as $token) {
$params = array_merge($params, $token->getRedirectUrlParams());
$params = array_merge($params, $token->params());
}
return $params;

View File

@ -123,19 +123,21 @@ class ConfirmationTokenChainTest extends SapphireTest {
}
public function testGetRedirectUrlParams() {
$mockToken = $this->getTokenRequiringReload(true, array('getRedirectUrlParams'));
$mockToken = $this->getTokenRequiringReload(true, array('params'));
$mockToken->expects($this->once())
->method('getRedirectUrlParams')
->method('params')
->will($this->returnValue(array('mockTokenParam' => '1')));
$secondMockToken = $this->getTokenRequiringReload(true, array('getRedirectUrlParams'));
$secondMockToken = $this->getTokenRequiringReload(true, array('params'));
$secondMockToken->expects($this->once())
->method('getRedirectUrlParams')
->method('params')
->will($this->returnValue(array('secondMockTokenParam' => '2')));
$chain = new ConfirmationTokenChain();
$chain->pushToken($mockToken);
$chain->pushToken($secondMockToken);
$this->assertEquals(array('mockTokenParam' => '1', 'secondMockTokenParam' => '2'), $chain->getRedirectUrlParams());
$params = $chain->getRedirectUrlParams();
$this->assertEquals('1', $params['mockTokenParam']);
$this->assertEquals('2', $params['secondMockTokenParam']);
}
}