-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Why RoleInterface will be removed on 4.0 release? #24043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The goal is to move away from the |
Is there any way of maintaining compatibility with the previous stream? How can we migrate to this new structure a paper system that is saved in a database, for example? |
I am not sure I understand your question. What do you mean with "paper system"? And how does it depend on your roles to be custom classes? |
@xabbuh My question is this: if my application have a Role entity with an attribute that represents the role. Today using 3.x version I create using the example below: class Group implements RoleInterface
{
use IdTrait;
/**
* @var string Name
*
* @ORM\Column(type="string", length=30)
*/
protected $name;
/**
* @var string Role identifier
*
* @ORM\Column(type="string", length=20, unique=true)
*/
protected $role;
/**
* @inheritDoc
*/
public function getRole()
{
return $this->role;
}
} Note that I use one trait in above example. I could have use a superclass and not a trait(IdTrait). The change made in Symfony 4.0, you changed the interface RoleInterface to superclass Role with the same method(getRole). I need change my class to example below: class Group extends Role
{
use IdTrait;
/**
* @var string Name
*
* @ORM\Column(type="string", length=30)
*/
protected $name;
/**
* @var string Role identifier
*
* @ORM\Column(type="string", length=20, unique=true)
*/
protected $role;
} Using my examples, I don't need work on many changes, but the old projects may have an old entity equal to example below: class Group extends AbstractEntity implements RoleInterface
{
/**
* @var string Name
*
* @ORM\Column(type="string", length=30)
*/
protected $name;
/**
* @var string Role identifier
*
* @ORM\Column(type="string", length=20, unique=true)
*/
protected $role;
/**
* @inheritDoc
*/
public function getRole()
{
return $this->role;
}
} On this last example, I have an superclass AbstractEntity and the interface RoleInterface implemented. I need work to change my code to change from superclass "AbstractEntity" to superclass "Role" and this can create a more fails in my code. Resume
$group instanceof Role == $group instanceof RoleInterface
Sorry for my bad english rs |
I see two possible solutions depending on what you need:
|
Closing as this has been answered. |
I don't see the harm in having the RoleInterface define a method getRole() to return a string? |
@delboy1978uk The concrete class will be deprecated in the future too. We just didn't manage to finish the PR for 3.4/4.0. |
I have no problems with concrete implementations being deprecated and removed, I just thought removing a contractual interface guaranteeing a string from a |
+1 on this issue. Would be nice to link to the discussion where the decision was made to understand the thought behind this. |
@xabbuh if a pull request wasn't finished, it show that this was a bad choice to remove the interface too early |
I have discovered this deprecation in the latest changelog, and i don't understand this change at all. |
Coming back to Symfony after a little time away, I came across some of these same considerations too. You can still use Role entities. You can handle roles however you want really. The only real security requirement that I can see is from the For example, you can instead change things to be a ManyToMany relationship between a |
Why the RoleInterface is deprecated and will be removed on 4.0 release?
The super class Role is a poor implementation, because the old projects entities can have a super class. The change(RoleInterface to super class Role) does not appear to have a technical justification.
The text was updated successfully, but these errors were encountered: