Question:

checking permissions after updating from laravel 5.7 to laravel 5.8 using silber/bouncer-rc5

Name: Miken
Score: 0
checking permissions after updating from laravel 5.7 to laravel 5.8 using silber/bouncer-rc5
-
I am using bouncer for my ACL needs and ever since upgrading my project from laravel 5.7 to 5.8 I've noticed a significant increase in the time it takes for my requests to process. I'm dealing with two models (let's call them Parent and Child), as well as the permissions the authenticated user has over them. I am using bouncer for my ACL needs and ever since upgrading my project from laravel 5.7 to 5.8 I've noticed a significant increase in the time it takes for my requests to process. I'm dealing with two models (let's call them Parent and Child), as well as the permissions the authenticated user has over them. // Takes about 110ms. Eager loads various nested relationships and counters with specific constraints $parents = Parent::myScope(...)->get(); // Bottleneck. Takes 5 minutes (!). Used to take about 40 seconds on laravel 5.7 $parents->each(function ($parent) { $parent->permissions = [ 'edit' => auth()->user()->can('edit', $parent), 'delete' => auth()->user()->can('delete', $parent), 'restore' => auth()->user()->can('restore', $parent) ]; $parent->children()->each(function ($child) { $child->permissions = [ 'edit' => auth()->user()->can('edit', $child), 'delete' => auth()->user()->can('delete', $child), 'restore' => auth()->user()->can('restore', $child) ]; } } I'm appending the permissions like this because the $parents variable will be sent as json to the front-end. I'm pretty sure this implementation is wrong, and must have a better alternative but the real issue is this inexplicable five-fold increase in loading time. The times were obtained using Debugbar measures. Using the monitor command in redis-cli (I'm using Redis to cache the permissions), I've noticed the GET requests come more slowly than before. In fact, even after I stop a page from loading (ESC), the GET requests to Redis don't stop immediately. I'm not sure if this is normal behavior or not. I tried to check the issues at the bouncer repo but I haven't found anything.
0 +
Tages : laravel
Answers :
Register / Login