-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
I'm using Symfony 2.6
system_users:
memory:
users:
my_admin: { password: "xxx", roles: 'ROLE_ADMIN' }
for that the container looks like:
/**
* Gets the 'security.user.provider.concrete.system_users' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* This service is private.
* If you want to be able to request this service from the container directly,
* make it public, otherwise you might end up with broken code.
*
* @param bool $lazyLoad whether to try lazy-loading the service with a proxy
*
* @return \Symfony\Component\Security\Core\User\InMemoryUserProvider A Symfony\Component\Security\Core\User\InMemoryUserProvider instance.
*/
public function getSecurity_User_Provider_Concrete_SystemUsersService($lazyLoad = true)
{
// (...)
$instance = new \Symfony\Component\Security\Core\User\InMemoryUserProvider();
$instance->createUser(new \Symfony\Component\Security\Core\User\User('my_admin', 'xxx', array(0 => 'ROLE_ADMIN')));
return $instance;
}
which is triggering an exception Call to a member function getRole() on a non-object:
(...)
Dec 19 15:28:54 damian-ThinkPad-T440p [3861]: PHP 18. XXX\Bundle\AdminBundle\Security\Voter\AdminAccessVoter->isGranted($attribute = uninitialized, $object = uninitialized, $user = uninitialized) /home/damian/PhpstormProjects/vendor-backend/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authorization/Voter/AbstractVoter.php:76
Dec 19 15:28:54 damian-ThinkPad-T440p [3861]: PHP 19. Symfony\Component\Security\Core\Role\RoleHierarchy->getReachableRoles($roles = uninitialized) /home/damian/PhpstormProjects/vendor-backend/src/XXX/Bundle/AdminBundle/Security/Voter/AdminAccessVoter.php:65
Dec 19 15:28:54 damian-ThinkPad-T440p [3861]: request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Error: Call to a member function getRole() on a non-object" at /home/damian/PhpstormProjects/vendor-backend/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php line 43 {"exception":"[object](Symfony\Component\Debug\Exception\FatalErrorException: Error: Call to a member function getRole%28%29 on a non-object at /home/damian/PhpstormProjects/vendor-backend/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php:43)"} []
as Core User code looks like:
private $roles;
public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
{
// ...
$this->roles = $roles;
}
/**
* {@inheritdoc}
*/
public function getRoles()
{
return $this->roles;
}
UserInterface::getRoles()
defines:
/**
* Returns the roles granted to the user.
* (...)
* @return Role[] The user roles
*/
public function getRoles();
Am I doing something wrong or it's a bug?