spatie / laravel-permission

Associate users with roles and permissions
https://spatie.be/docs/laravel-permission
MIT License
12.2k stars 1.78k forks source link

new cache permissions gone #927

Closed universenl closed 6 years ago

universenl commented 6 years ago

Hello,

I am trying to get my new web app live, but for this time i run into some trouble. It seems when ever the storage/cache/data/85/ file is cleaned laravel spatie is not getting my admin permissions anymore. When i replace the cache file with an older one it seems to work again.

Can somebody please assist on this, already got more than 20 hours in this problem. Added both of the cache files

855f92484c8c414d36c1b25cb24876e30229cbbf_new but not working.txt 855f92484c8c414d36c1b25cb24876e30229cbbf_working.txt

Greatings Mitch

drbyte commented 6 years ago

It seems when ever the storage/cache/data/85/ file is cleaned

What is doing the "cleaning" of files in your storage folder?

universenl commented 6 years ago

Not sure thats the problem, everyday this happends again so i need to overwrite the file to get the admin permissions back.It seems like everyday that file to created again, and when that happened i lost admin permissions.

drbyte commented 6 years ago

Well, the problem could be in 4 places:

universenl commented 6 years ago

Its seems like something on the production server, becouse the development still runs without any errors. Same version of the application only not in production build.

It seems like when we save a permission this error occurs right away, so if i save the permission All on the adminpanel we get locked out and the cache file is changed.

The wierd thing about this story, we did run the backend in production mode for like 6 weeks without this error occurs once. But like i sad, the development version still runs string and even there we can save the All permissions and the website still works.

drbyte commented 6 years ago

Ya, it seems like something odd on the server.

The package does delete cached permissions on save, but rebuilds them again on the first query.

Again, switching from file-based caching to a different cache driver may reveal something useful in your debugging process. Instead of file, try array. Then you can try database if you create the cache table in the db (run php artisan cache:table to create a migration for that table). If you have redis on your server, you can install predis/predis with composer and change to redis for your cache driver.

You didn't mention which Laravel version.
What's the content of your composer.json?

universenl commented 6 years ago

This is composer.json

{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": "^7.1.3", "barryvdh/laravel-dompdf": "^0.8.2", "dennobaby/autodns-api-2": "dev-master", "fideloper/proxy": "^4.0", "gtk/flash-message": "^1.3", "imtigger/laravel-job-status": "^0.1.14", "itelmenko/laravel-mysql-logger": "^0.1.8", "laravel/framework": "5.7.*", "laravel/tinker": "^1.0", "laravelcollective/html": "^5.6", "laravelcollective/remote": "^5.6", "mariuzzo/laravel-js-localization": "^1.4", "mollie/laravel-mollie": "^2.0", "nyholm/psr7": "^1.0", "propaganistas/laravel-phone": "^4.0", "pusher/pusher-php-server": "~3.0", "spatie/laravel-newsletter": "^4.2", "spatie/laravel-permission": "^2.12", "unisharp/laravel-filemanager": "~1.8", "yajra/laravel-datatables-oracle": "~8.0" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.1", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^2.0", "phpunit/phpunit": "^7.0" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/" }, "files": [ "app/Helpers/cdn.php", "app/Helpers/functions.php", "app/Helpers/formatting.php", "app/Helpers/user.php" ] }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "extra": { "laravel": { "dont-discover": [ ] } }, "scripts": { "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true }, "minimum-stability": "dev", "prefer-stable": true }

universenl commented 6 years ago

This is fixed, wrong id in mysql was the problem.