Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem Motivation
The installer checks $readability and $writability of the settings file, defaults it to FALSE but only checks it in one of three cases. When the file already exists. So when the file is automatically created, there is a requirement file claiming that it can't be read. And when you refresh the page, then it works.
Steps to reproduce:
- Remove settings.php if you have it.
- Give the apache user write permission of the directory
- Start the installer.
- You get the settings.php can not be read error.
- Refresh page.
- Now it works.
Proposed resolution
See #5: set $readable and $writable again.
Remaining tasks
- (done) patch test bot likes in #1 by Berdir
- (done) manual testing in #2 by maryedith
- (done) code review in #5, #6, and #7 by chx, David_Rothstein, sun
- (done) code standards review ... agreed this is fine in #8, #9
User interface changes
none.
API changes
none.
Comment | File | Size | Author |
---|---|---|---|
#1 | settings-readable-check-1805324-1.patch | 1.32 KB | Berdir |
Comments
Comment #1
BerdirAttaching a patch. $writable actually currently checks both.
Alternatively, we could also remove the separte settings.php is not readable check and change the text of the other one.
Comment #2
maryedith CreditAttribution: maryedith commentedI started with a clean git of 8.x-dev. when I started the installation I observed the error. Verified that the bug still exists.
Found this issue, downloaded the patch from http://drupal.org/files/settings-readable-check-1805324-1.patch
Made a new branch , applied the patch in the new branch.
Deleted my setting.php in order to restart the install.
Went back to initial installation of this Drupal install,
The error did not occur. Proceded directly to the Database setup page rather than having the error.
This patch fixes the bug.
Next step is to get a code review.
Comment #3
znerol CreditAttribution: znerol commentedPatch seems sane and fixes the problem.
Comment #4
webchickIt would be great to get a couple of more reviews on this, from sun or chx for example.
Comment #5
chx CreditAttribution: chx commentedSo what happens to $readable? It starts as FALSE and in current HEAD only gets flipped to TRUE if the dir and settings file both exist already. Otherwise we copy the default to settings.php and... forget to set $readable. There's some dance happening after the copying which is amply documented but anyways indeed you will get a readable error because we do not set $readable and when you reload then it'll be set because again, that's the only way it is -- when the file already exists. The patch is correct.
Comment #6
David_Rothstein CreditAttribution: David_Rothstein commentedDidn't test it out, but reading the patch and surrounding code it makes sense to me also.
I was confused because I was quite sure based on previous experience that this bug didn't actually exist (for example, in Drupal 7), so I checked a bit and it turns out it was introduced relatively recently (and for Drupal 8 only) via #1542620: Fatal errors when file permissions for settings.php are messed up (can't read file)
Comment #7
sunYep, this is essentially the same fix as in #1798732: Convert install_task, install_time and install_current_batch to use the state system
That said, I studied what the called code is doing (which is anything but trivial) and concluded that the returned value can be assigned to both $readable and $writeable, as in:
However, we can also check them separately — doesn't make much of a difference.
Comment #8
BerdirThanks for the reviews.
@sun: Right, that works technically too. But I think it's against our coding standards to do double assignments like that. Don't know if it's documented but I know patches of me were set to needs work because of such things.
Comment #9
sunYeah, very sad panda. Commenting on this would only circle back into #1791872: [Policy, no patch] Add special tag to identify issues ready for a high level only review... so I refrain from that and that's why I'm fine with the duplicate invocation.
Someone will ask whether we cannot do a simple
$readable = $writable;
assignment on a second line, but that would be even more confusing than the double variable assignment. At least in my book.Comment #10
YesCT CreditAttribution: YesCT commentedSince I was reading the comments to catch up on the progress here, I updated the issue summary.
@webchick, I think your concerns from #4 have been address and this is ready.
Comment #11
webchickOh, nice! It turns out this issue has been driving me nuts while I've been testing Spark. :) Nice to see a fix! And thanks for the extra reviews.
Committed and pushed to 8.x. Thanks!
Comment #12.0
(not verified) CreditAttribution: commentedUpdated issue summary to reflect code review done.