config->write() currently uses file_put_contents() to write files, withour calling drupal_chmod() to look after the permissions of those files. Presumably that was done because drupal_chmod() depended on config. This patch moves the chmod variables to the settings system so that they are available very early, like when we write out config files during the installer.
The main benefit here is that config files can now be writable by both webserver and cli user and thus all sorts of drush commands are able to work without disrupting web admin users (config commands, pm-enable, ...).
This patch enables us to roll back #2099467: Let non-interactive installers determine mode of files directory and its subdirectories as it is this patch fixes that need, and more.
Comment | File | Size | Author |
---|---|---|---|
#13 | chmod.diff | 21.5 KB | moshe weitzman |
#11 | chmod.diff | 21.77 KB | moshe weitzman |
#9 | chmod.diff | 21.16 KB | moshe weitzman |
#7 | chmod.diff | 11.73 KB | moshe weitzman |
#4 | chmod.diff | 11.92 KB | moshe weitzman |
Comments
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedFix install bug I hope
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedFixed the fails. The warnings from he Upgrade tests are eluding me. I could use some help here The upgrade tests do some fun cleverness that is giving harmless warning it seems.
Comment #6
chx CreditAttribution: chx commentedI think the removal of upgrade tests will help.
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedJust a reroll. Let's see.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedSimplified a little since stream wrappers are not declared when we are writing config in installer. Also included a rollback of #2099467: Let non-interactive installers determine mode of files directory and its subdirectories as promised in the Summary. That code is no longer needed.
The attached format-patch has 2 commits in it so folks can see the new code separate from the rollback, and still get it all tested by the bot.
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedComment #11
moshe weitzman CreditAttribution: moshe weitzman commentedNow with 2 new assertions which validate that these settings work.
Comment #12
sun1. Can we define the constant values are octals instead of strings?
2. I think the constant names should be prefixed with "FILE_". And because they're constants, I'm not sure whether the "DEFAULT_" in their names is required? How about these:
FILE_CHMOD_DIRECTORY
FILE_CHMOD_FILE
3. Do we actually know why we're diverging from the PHP defaults? (at least mkdir() defaults to 0777)
Given that the values are moved entirely out of the config system and are only ever set in PHP now, the entire string to octdec() conversion appears to be obsolete?
Consuming code either gets the setting from settings.php (PHP) or the constant value from file.inc (PHP).
Thus, there are no more strings anywhere at all and we can use raw octals everywhere?
Given that we also plan to move the private/temporary filesystem paths into settings, I'm a bit concerned about the resulting DX in settings.php — we'll end up with this:
I wonder whether we're able to plan ahead of time already?
In an ideal world, I think I'd consider this:
Hm. Actually, the proposed $settings keys here appear to be fine, since they're not related to stream wrappers - or much rather, they apply to all local filesystem stream wrappers.
That said, to underline 1.2, a naming consistency between
$settings['file_chmod_directory']
and theFILE_CHMOD_DIRECTORY
constant would make most sense to me.Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedSimplified per 1,2 in Sun's review.
Comment #14
sunThis looks ready to me, in case testbot comes back green.
Comment #15
moshe weitzman CreditAttribution: moshe weitzman commentedAlex worked with me on #2099467: Let non-interactive installers determine mode of files directory and its subdirectories in Prague so perhaps he should preside over its rollback.
Comment #16
alexpottLooks like a sensible and better approach than #2099467: Let non-interactive installers determine mode of files directory and its subdirectories - this is committable once major and critical week is over
Comment #17
webchickLooks like Alex has got this.
Comment #18
alexpottCommitted a3c8c88 and pushed to 8.x. Thanks!
I think we need a change notice to explain how it is different from Drupal 7.
Comment #19
j4 CreditAttribution: j4 commentedAdded Change Record.
Comment #20
alexpott@j4 the point of the change notice is to tell people how this was configured in Drupal 7
Is now...
in Drupal 8
Also the reason we are making this change is because the variable system is being replace by configuration stored in files and, therefore, we can not store this in configuration.
Comment #21
j4 CreditAttribution: j4 commentedHave added this. Sorry this was my first time in trying to create change records..thank you for the explanation.
Jaya
Comment #22
geerlingguy CreditAttribution: geerlingguy commentedI'm not 100% sure if this is related to my issue or not, as I haven't had tons of time to dig... but if I use Drush (latest master version from GitHub) and download drupal-8.x dev, then do a drush site-install, the install completes successfully, and
drush status
works perfectly, but Drupal keeps giving me the 'you probably need to rebuild' message.I tracked it down to the settings.php file having 444 permissions—if I switched to 744, then loaded the page again, everything worked great. I went back to 444 after that, and things kept working. So it seems if I do a drush site-install, then pop over to the web browser, some final thing needs to be written to settings.php but can't be.
Until I updated those permissions, I got the rebuild message in the browser, and the following in Apache's error log:
Maybe drush site-install is where the problem lies? I have no idea, but will investigate later if I'm able.
Comment #23
moshe weitzman CreditAttribution: moshe weitzman commentedUpdate title to match patch that was committed. Also updated the change record a bit.
@geerlingguy - please do share your findings if you get back to debugging your issue.
Comment #24
geerlingguy CreditAttribution: geerlingguy commented@moshe - will do. For now, I've left comments everywhere someone else might find potential solutions, hopefully that helps others who get stuck in the same rut.
Comment #25
xjmThe change record here could use a bit of work. Before-and-after examples for D7 and D8 would be very helpful, and the text is not very clear.
Comment #26
xjmComment #27
moshe weitzman CreditAttribution: moshe weitzman commentedCleaned up change record.
Comment #28
benjy CreditAttribution: benjy commentedThis issue introduce a bug in file_unmanaged_copy() https://drupal.org/node/2191631
Comment #29
benjy CreditAttribution: benjy commentedSorry, it looks like the bug has been around for a while. I wrongly presumed it was this patch that caused the issue since it was so recent and the bug seemed like something that would have been caught fairly quick.
Comment #31
sun