admin管理员组文章数量:1414605
I ran into an issue today with files uploaded through the Wordpress Backend not getting the correct permissions. The permission on the new 2018 folder in the uploads directory as well as the files within it were too tight, the webserver user couldn't even access them. I found the constants FS_CHMOD_DIR
and FS_CHMOD_FILE
that can be used to overwrite the default permissions for uploaded files. The Wordpress Codex suggests using the the following settings in the wp-config.php
:
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) );
However, I haven't been able to find documentation on the syntax of those constants. The octal notation of the permissions is clear, but what is up with the ampersand, the swung dash and the umask command without a parameter? This article by wpbeginner mentions those constants as well, however it only mentions defining the constants with the octal values alone. What's the difference between that and the longer command above?
I ran into an issue today with files uploaded through the Wordpress Backend not getting the correct permissions. The permission on the new 2018 folder in the uploads directory as well as the files within it were too tight, the webserver user couldn't even access them. I found the constants FS_CHMOD_DIR
and FS_CHMOD_FILE
that can be used to overwrite the default permissions for uploaded files. The Wordpress Codex suggests using the the following settings in the wp-config.php
:
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) );
However, I haven't been able to find documentation on the syntax of those constants. The octal notation of the permissions is clear, but what is up with the ampersand, the swung dash and the umask command without a parameter? This article by wpbeginner mentions those constants as well, however it only mentions defining the constants with the octal values alone. What's the difference between that and the longer command above?
Share Improve this question asked Jan 5, 2018 at 10:18 MoritzLostMoritzLost 1771 silver badge8 bronze badges1 Answer
Reset to default 4The basic syntax for define() is:
define ( $name, $value )
In the above definition, the value is:
( 0755 & ~ umask() )
The '&' (ampersand) is the 'And' bitwise operator, the '~' (tilde) is the 'Not' bitwise operator, and the umask() function returns the current umask.
To answer your question in short (if your are interested in learning bitwise operations, there are plenty of resources on that), the above "syntax" is in fact an operation, that substracts the current umask from the definition you provide.
So, for example, if you provide 0644 and the current umask is 0640, then the effective permissions set will be 640. Why or when would you do that? Well, you would in the cases where you want to specify certain permissions, but not being more permissive than the default umask.
本文标签: wp configSyntax of FSCHMODDIR and FSCHMODFILE
版权声明:本文标题:wp config - Syntax of FS_CHMOD_DIR and FS_CHMOD_FILE 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745148216a2644796.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论