Make WordPress Core

Opened 8 years ago

Last modified 6 years ago

#35823 new enhancement

Implement "FS_CHMOD_FORCE" constant; if set - media uploads and image resizing do NOT ignore FS_CHMOD_FILE

Reported by: profforg's profile Profforg Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Upload Keywords:
Focuses: Cc:



I want to re-open

I think that it's very strange to not giving an ability to globally override file permissions. Even though WP lead developers thinks that it's "not good" to use FS_CHMOD_FILE on file uploads - there should be a way to do it. It will not be default. Default behaviour won't be changed. Filters or other ways are a madness for users with many websites on board or for hosting providers which want to set basic options forcefully.

The problem:
One may expect that after setting constant FS_CHMOD_FILE - all files created or modified (maybe) by WordPress will have FS_CHMOD_FILE permissions. But for some wierd reason it is not so. I can understand the explanation from 21251 ticket. So it can be solved by creating a new constant which control the behaviour.

I've attached a patch which changes upload function's logic to understand FS_CHMOD_FORCE constant and honor it if it is defined. If it is not defined (default), behaviour will be the same as it was before.

After applied patch it will be possible to set the following in wp-config.php or globally:

define('FS_CHMOD_FILE', 0640);
define('FS_CHMOD_FORCE', 1);

so all uploaded files will be uploaded with 0640 chmod. 0640 can be changed to desired value for sure, this is just an example.

Attachments (1)

patch.patch (3.1 KB) - added by Profforg 8 years ago.

Download all attachments as: .zip

Change History (4)

8 years ago

#1 @chriscct7
8 years ago

  • Version trunk deleted

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

6 years ago

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

6 years ago

Note: See TracTickets for help on using tickets.