Merge branch '2.3' into 2.7
* 2.3: [HttpFoundation] Improve phpdoc [Logging] Add support for firefox in ChromePhpHandler [Security] Fixed SwitchUserListener when exiting an impersonication with AnonymousToken [Form] fix "prototype" not required when parent form is not required
This commit is contained in:
commit
034f47635c
@ -41,7 +41,7 @@ class ChromePhpHandler extends BaseChromePhpHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('{\bChrome/\d+[\.\d+]*\b}', $event->getRequest()->headers->get('User-Agent'))) {
|
if (!preg_match('{\b(?:Chrome/\d+(?:\.\d+)*|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}', $event->getRequest()->headers->get('User-Agent'))) {
|
||||||
$this->sendHeaders = false;
|
$this->sendHeaders = false;
|
||||||
$this->headers = array();
|
$this->headers = array();
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ class CollectionType extends AbstractType
|
|||||||
));
|
));
|
||||||
|
|
||||||
if ($form->getConfig()->hasAttribute('prototype')) {
|
if ($form->getConfig()->hasAttribute('prototype')) {
|
||||||
$view->vars['prototype'] = $form->getConfig()->getAttribute('prototype')->createView($view);
|
$prototype = $form->getConfig()->getAttribute('prototype');
|
||||||
|
$view->vars['prototype'] = $prototype->setParent($form)->createView($view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,4 +300,46 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
$this->assertFalse($form->createView()->vars['required'], 'collection is not required');
|
$this->assertFalse($form->createView()->vars['required'], 'collection is not required');
|
||||||
$this->assertFalse($form->createView()->vars['prototype']->vars['required'], '"prototype" should not be required');
|
$this->assertFalse($form->createView()->vars['prototype']->vars['required'], '"prototype" should not be required');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPrototypeSetNotRequiredIfParentNotRequired()
|
||||||
|
{
|
||||||
|
$child = $this->factory->create('collection', array(), array(
|
||||||
|
'type' => 'file',
|
||||||
|
'allow_add' => true,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__test__',
|
||||||
|
));
|
||||||
|
|
||||||
|
$parent = $this->factory->create('form', array(), array(
|
||||||
|
'required' => false,
|
||||||
|
));
|
||||||
|
|
||||||
|
$child->setParent($parent);
|
||||||
|
$this->assertFalse($parent->createView()->vars['required'], 'Parent is not required');
|
||||||
|
$this->assertFalse($child->createView()->vars['required'], 'Child is not required');
|
||||||
|
$this->assertFalse($child->createView()->vars['prototype']->vars['required'], '"Prototype" should not be required');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPrototypeNotOverrideRequiredByEntryOptionsInFavorOfParent()
|
||||||
|
{
|
||||||
|
$child = $this->factory->create('collection', array(), array(
|
||||||
|
'type' => 'file',
|
||||||
|
'allow_add' => true,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__test__',
|
||||||
|
'options' => array(
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
$parent = $this->factory->create('form', array(), array(
|
||||||
|
'required' => false,
|
||||||
|
));
|
||||||
|
|
||||||
|
$child->setParent($parent);
|
||||||
|
|
||||||
|
$this->assertFalse($parent->createView()->vars['required'], 'Parent is not required');
|
||||||
|
$this->assertFalse($child->createView()->vars['required'], 'Child is not required');
|
||||||
|
$this->assertFalse($child->createView()->vars['prototype']->vars['required'], '"Prototype" should not be required');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ class Request
|
|||||||
* public property instead (query, attributes, request).
|
* public property instead (query, attributes, request).
|
||||||
*
|
*
|
||||||
* @param string $key the key
|
* @param string $key the key
|
||||||
* @param mixed $default the default value
|
* @param mixed $default the default value if the parameter key does not exist
|
||||||
* @param bool $deep is parameter deep in multidimensional array
|
* @param bool $deep is parameter deep in multidimensional array
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Firewall;
|
namespace Symfony\Component\Security\Http\Firewall;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||||
@ -161,7 +162,7 @@ class SwitchUserListener implements ListenerInterface
|
|||||||
throw new AuthenticationCredentialsNotFoundException('Could not find original Token object.');
|
throw new AuthenticationCredentialsNotFoundException('Could not find original Token object.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->dispatcher) {
|
if (null !== $this->dispatcher && $original->getUser() instanceof UserInterface) {
|
||||||
$user = $this->provider->refreshUser($original->getUser());
|
$user = $this->provider->refreshUser($original->getUser());
|
||||||
$switchEvent = new SwitchUserEvent($request, $user);
|
$switchEvent = new SwitchUserEvent($request, $user);
|
||||||
$this->dispatcher->dispatch(SecurityEvents::SWITCH_USER, $switchEvent);
|
$this->dispatcher->dispatch(SecurityEvents::SWITCH_USER, $switchEvent);
|
||||||
|
@ -158,6 +158,54 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$listener->handle($this->event);
|
$listener->handle($this->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testExitUserDoesNotDispatchEventWithStringUser()
|
||||||
|
{
|
||||||
|
$originalUser = 'anon.';
|
||||||
|
$refreshedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
|
||||||
|
$this
|
||||||
|
->userProvider
|
||||||
|
->expects($this->never())
|
||||||
|
->method('refreshUser');
|
||||||
|
$originalToken = $this->getToken();
|
||||||
|
$originalToken
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getUser')
|
||||||
|
->willReturn($originalUser);
|
||||||
|
$role = $this
|
||||||
|
->getMockBuilder('Symfony\Component\Security\Core\Role\SwitchUserRole')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$role
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getSource')
|
||||||
|
->willReturn($originalToken);
|
||||||
|
$this
|
||||||
|
->tokenStorage
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getToken')
|
||||||
|
->willReturn($this->getToken(array($role)));
|
||||||
|
$this
|
||||||
|
->request
|
||||||
|
->expects($this->any())
|
||||||
|
->method('all')
|
||||||
|
->with('_switch_user')
|
||||||
|
->willReturn('_exit');
|
||||||
|
$this
|
||||||
|
->request
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getUri')
|
||||||
|
->willReturn('/');
|
||||||
|
|
||||||
|
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||||
|
$dispatcher
|
||||||
|
->expects($this->never())
|
||||||
|
->method('dispatch')
|
||||||
|
;
|
||||||
|
|
||||||
|
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager, null, '_switch_user', 'ROLE_ALLOWED_TO_SWITCH', $dispatcher);
|
||||||
|
$listener->handle($this->event);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
|
* @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user