Closed RdeWilde closed 3 years ago
PHP downgrades your permissions if you haven't disabled this feature manually.
It is required to add umask(0000);
somewhere before cache is used. I usually add this to bootstrap/app.php
.
Check your code for umask
- if it is not set or not 0000
- then this is the reason why 0777
permissions are ignored
Thanks for your fast response @swayok I understand what you are saying. When I look in the Local-adapter it seems to already reset the umask: https://github.com/thephpleague/flysystem/blob/1.x/src/Adapter/Local.php#L101
I also replaced the permissionMap with a static 0777 value - https://github.com/thephpleague/flysystem/blob/1.x/src/Adapter/Local.php#L103 - the directories were created, but still not with 0777 permissions.
Do you know what I can look at next?
Listing for reference, possibly related: https://github.com/thephpleague/flysystem/issues/1181 I am using 1.1.3 though, so won't fix my problem
Might still be an issue with PHP (config). I added this as first line to my index.php
umask(0);
@mkdir('test', 0777, true);
Still the directory is not created with 777-permission.
guess it is not related to your code.
This is quite strange. umask
is the only thing that controls permissions in PHP as I know.
Try to do @rmdir('test')
to be sure directory not exists before creaton. @mkdir('test', 0777, true);
will not change permissions if directory already exists.
And also try chmod('test', 0777);
after creation. Maybe something wrong with mkdir
.
If directory is still not 0777 - then it probably OS config somehow alters permissions.
chmod
does work, without it - it does not. But obviously this is not default implemented in the vendor's code.
Thanks for your help, I'll keep digging.
Just to clarify - do you delete created folder each time you run the script?
No
That is the reason why permissions are not updated unless you call chmod('test', 0777);
.
@mkdir('test', 0777, true);
will never change permissions on already existing folder.
Try his code:
@rmdir('test');
umask(0);
@mkdir('test', 0777, true);
Now directory should have 0777 permissions. If not - look for PHP or Linux restrictions.
Also this might be the reason why your cache folder haven't changed permissions according to config changes. If folder was created with 0755 permissions - then it will not ever change this permissions unless you delete it or use chmod
on it.
In the readme.md file is an example on passing the permissions-configuration for file-based cache drivers in config/cache.php
I did literally copy the example code and change both public permissions to 0777, but files and directories are still being created with 644 etc. I recreated the config, so it is not a cached config. Also looked at #9 but that did not provide a solution.
Any clue? Any info I should provide?
When I dump
$cacheConfig
in makeFileCacheAdapter from AlternativeCacheStoresServiceProvider.php, I do get the right values:Also in vendor/league/flysystem/src/Adapter/Local.php::__construct I get the right values