-
Notifications
You must be signed in to change notification settings - Fork 6
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
Removed Zfc/Rbac dependency and passed all the tests with some changes. #36
Removed Zfc/Rbac dependency and passed all the tests with some changes. #36
Conversation
…s in tests. Signed-off-by: Mubashir <[email protected]>
cf8fe64
to
81e48b9
Compare
Thanks @ALTAMASH80. |
Hi @visto9259, |
Hi @visto9259, just wanted did you get the time to go through the changes. You did say you'll look at it in August. Threfore, I thought I should give you a reminder. Thanks! |
Hi @ALTAMASH80, Thanks for the reminder. I've been busy with many non-work related issues. I will take a look shortly |
Hi @visto9259, I just wanted to know about the progress of removing the dependency of zfc-rbac. Are there any issues with the current commit that need to be resolved? Thanks! |
Any movement on this? |
@dkmuir, I've presented my solution and it is working. A review is required before merging. So, I'm still waiting for it to be merged into the official repo. Thanks! |
This is long overdue on my end to look into. I will get to it. |
I'm eagerly waiting for my first major contribution. I hope it will help someone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my review comments.
It needs work before we can merge into branch 4x-dev.
I need to think about getting rid of anything that we are adding to the Laminas-permissions-rbac library, even if it means have backward compatibility issues. zf-fr Rbac was, as I understand it, a precursor to laminas-permissions-rbac. If we are not using these extensions within lmc-rbac-mvc, then I think we should get rid of them.
Otherwise, that was a lot a work on your part. Thanks for the input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 63, there is a mocking of Rbac\Rbac again that should be removed.
/* @var Rbac $rbac */ | ||
$rbac = $container->get(Rbac::class); | ||
/* @var \Laminas\Permissions\Rbac\Rbac $rbac */ | ||
$rbac = $container->get(\Rbac\Rbac::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should not be any reference to Rbac\Rbac as a service.
It passed the tests because Rbac\Rbac is being mocked in the Factory test suite. See comments in the corresponsind Test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, the service 'Rbac\Rbac' is defined in module.config.php and it should not since there is no longer a namespace called 'Rbac'
@@ -31,7 +31,7 @@ public function testFactory() | |||
{ | |||
$serviceManager = new ServiceManager(); | |||
|
|||
$serviceManager->setService('Rbac\Rbac', $this->getMockBuilder('Rbac\Rbac')->disableOriginalConstructor()->getMock()); | |||
$serviceManager->setService('Rbac\Rbac', $this->getMockBuilder(\LmcRbacMvc\Rbac\Rbac::class)->disableOriginalConstructor()->getMock()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not be mocking the Rbac\Rbac service since it defeats the purpose of removing references to Rbac and make the test pass when it should not have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@visto9259, the service call here is accessing LmcRbac\Rbac as defined here..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know but this is misleading. Since we are removing references to Rbac\Rbac
, we should not have a service that creates an object called Rbac\Rbac
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want the Rbac\Rbac to be removed it may lead to a backward compatibility break. I kept it because I saw something similar in Laminas MVC to keep backward compatibility. If the service name should also be changed, I'll change it. Thanks!
@@ -19,7 +19,7 @@ | |||
namespace LmcRbacMvc\Factory; | |||
|
|||
use Psr\Container\ContainerInterface; | |||
use Rbac\Rbac; | |||
use LmcRbacMvc\Rbac\Rbac; | |||
use Rbac\Traversal\Strategy\GeneratorStrategy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reference to Rbac needs to be removed
@@ -154,7 +153,7 @@ private function collectIdentityRolesAndPermissions(RoleService $roleService) | |||
foreach ($identityRoles as $role) { | |||
$roleName = $role->getName(); | |||
|
|||
if (!$role instanceof HierarchicalRoleInterface) { | |||
if (empty($role->hasChildren())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasChildren() returns a boolean.
this should be if (!$role->hasChildren()) instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not review this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not review this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not review this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
Since it comes from zf-fr Rbac, is it being used somewhere within LmcRbacMvc? If not, then I think we should not bring it in LmcRbacMvc
src/Role/RecursiveRoleIterator.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
Since it comes from zf-fr Rbac, is it being used somewhere within LmcRbacMvc? If not, then I think we should not bring it in LmcRbacMvc
@ALTAMASH80 Thanks for the effort. |
Hi @visto9259, I'll check it again and will get back to you. Thanks for the very precise comments. |
Hi @ALTAMASH80. You're welcomed. |
I'll check it again that how come an \Rbac\Rbac instance is compatible with the \LmcRbac\Rbac. The reference \Rbac\Rbac::class remained only as a service name accessibility. But, what you've just shown I can't deny that and it is indeed very helpful. To remove the zfr\Rbac extension traces completely, I may not be able to do that as it will require modification in the current tests as well. Because of the fact it also contains a non-hierarchal permission which will not be compatible with hierachal permission. That is why traces of some zfr-rbac remain. |
@ALTAMASH80 There is an important difference between Laminas Overall, Test cases will need to be adjusted to take into account these changes. Let me know if this makes sense and if you need help. |
Hi, @visto9259 the changes which you want I'm not capable of doing it. I can fix a test but can't create a test. I've not yet understood the philosophy of the LMCRbac and I don't even know how the first test was created and why. I'm just a tool user, not a creator. I can't write tests and I also don't understand the tests which are there in the LmcRbac. Therefore to change or replace a key class, I'm not well versed in that. I hope someone comes up and fix that. I can only make it usable for PHP8 and remove zfr-rbac. But to change their ideology and what they've implemented I can't do that. I hope I've explained myself. Thanks! |
@ALTAMASH80 Thanks for your contribution and this PR. |
Hi @visto9259, I've checked the code myself and I've not found any Rbac\Rbac instance getting created and all the tests passed. I think you're confused with the usage of 'Rbac\Rbac' and \Rbac\Rbac::class. Essentially both are the same thing. This is used because the service is created by the name 'Rbac\Rbac'; therefore, you assume it is creating a zfr-rbac instance. The instance which is getting returned is the Laminas\Permissions\Rbac. In my opinion this branch is ready to be merged. You can create another enhancement feature to remove 'Rbac\Rbac' service name and replace it with LmcRbacMVC\Rbac or anything you choose. Then we can work on separating doctrine from this repository. Thanks! |
@ALTAMASH80 |
@visto9259, |
The 4.x-dev branch for all work related to V4 and new development. |
So, according to your liking, this work I've done is not up to mark for the 4.0? I thought it was. I'm crying! So, I should not expect a raise which I thought I was going to get. I bought a mansion on a big lease. Well, I've to call them off. Thanks! |
Only RbacCollecterTest remains to pass.