Wrong permissions (Group/user) for the occasional cache file in Laravel

Viewed 492

I've set all the permissions up and everything has been working perfectly for about 2 years until today when I force cleared the cache using php artisan cache:clear

Now, when the cache gets created in /storage/framework/cache, it works fine and all the permissions are set correctly except for the occasional file.

I could have thousands of cache files in there, all with the correct permissions (www-data as user and group). . but then randomly one file will generate using the wrong permissions which ends up with this error.

 file_put_contents(/.../.../storage/framework/cache/data/52/cf/52cf02760233b9fc625602f52fd0748a51ac772a): failed to open stream: Permission denied

When I navigate to the file, the permissions are set to 744 and the user/group is set to root:root. Every other cache file is set to 774 and www-data:www-data.

I can fix it temporarily by running sudo chown -R www-data:www-data storage which sets the folders to the correct group and user but then the error appears again after about 15 minute once another file generates with the incorrect permissions.

What can be causing this?

0 Answers
Related