Closed swati-clarion closed 8 years ago
Recursion?
This is an automated comment, triggered by adding the label question
.
Please note, that the GitHub Issue Tracker is for bug reports and feature requests only.
We are happy to help you on the support forum, on IRC (#yii on freenode), or Gitter.
Please use one of the above mentioned resources to discuss the problem. If the result of the discussion turns out that there really is a bug in the framework, feel free to come back and provide information on how to reproduce the issue. This issue will be closed for now.
I am using rbac for setting permissions to each user and check permission for each action using if Yii::$app->user->can() method. For example, if (Yii::$app->user->can('View-all-Inventory')) This was working properly until I recently added 2 new permissions in auth-item DB table and allotted them to parent Super-Administrator.
After this, I suddenly started getting following fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) using rbac
I checked and applied many solutions for this, but this error remains as it. I can see this error on my localhost using xampp and also at live server.
I have increased memory limit to 256M and further increased upto 512M. Still I am getting same error. I disabled Yii2 debugger and set environment to LIVE. Still it didnot help. I was getting error in getChildrenRecursive function with logger. Further debugging, I found that when I comment code inside public function checkAccess and simply return true, everything seems to be working as before with no more errors. Commenting this is temporary solution, but i had to this on LIVE server to avoid errors on LIVE site.
But, I think the issue is with recursive function checkAccessRecursive. It is being recursively called many times which causes memory limit to exhaust. Can you please suggest how to optimize this function , I have only 2 level of hierarchy i.e one parent has many children but any child donot have further children.
I am struck and not sure how to sort this and allow access using permissions.