Install fails when default.settings.php is not present
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | install system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
| Issue tags: | DrupalWTF |
Hi,
the Installer of D7,actual HEAD fails after entering the DB and the DB login with
Warning: fopen(/var/www/d7test/drupal/sites/default/default.settings.php) [function.fopen]: failed to open stream: No such file or directory in /var/www/d7test/drupal/includes/install.inc on line 345
Warning: Cannot modify header information - headers already sent by (output started at /var/www/d7test/drupal/includes/install.inc:345) in /var/www/d7test/drupal/includes/install.inc on line 802
Warning: Cannot modify header information - headers already sent by (output started at /var/www/d7test/drupal/includes/install.inc:345) in /var/www/d7test/drupal/includes/install.inc on line 803
it's possible to workaround this by the attached patch, but i've no idea if this doesn't break other stuff like multisites...
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| installpatch.patch | 642 bytes | Idle | Failed: Failed to install HEAD. | View details | Re-test |
| installpatch.patch | 1.02 KB | Idle | Failed: Failed to apply patch. | View details | Re-test |

#1
That's weird. What files do you have listed in the sites folder of your drupal install?
#2
I talked to dave on irc about this, and we came to the conclusion that the installer needs default.settings.php and settings.php, I renamed the default.settings.php to settings.php instead of copying it...
The new bug is now that the installer needs to issue an Error of default.settings.php doesn't exist. I'll try to come up with a patch for this tomorrow.
#3
Fixed title spelling error. Once you get your patch written, I'll help test!
#4
I've a patch present but it needs #312677: drupal_verify_install_file sometimes issues a php warning resolved first, so I'm marking this as postponed. Also this is not critical anymore (the installer doesn't fail always), so I'm marking this as normal.
#5
As #312677: drupal_verify_install_file sometimes issues a php warning should get in soon, I'm pposting my patch for review here. The warning when default.settings.php is fixed after applying my patch from the other issue.
#6
The error message should mention the fact default.settings.php needs to match the one that is delivered with Drupal. One that exists and is empty or a modified settings.php is of no value.
#7
This reroll fixes some whitespace issues of my code and adds a md5-check of default.settings.php with an extra message. This needs to be updated every time default.settings.php changes...
#8
no comment -.-
#9
Both the default Drupal message about a missing settings.php as the new settings.default.php are talking about permissions, but only the first message actually provides a link to a handbook page about settings those permissions. I would use this link as a separate message that is being displayed if either settings.php or settings.default.php are missing.
I also think the original message could then be made smaller. Before:
More details about installing Drupal are available in INSTALL.txt.
After:
$file would be 'settings.php' or 'settings.default.php' or a combination of the two, depending on which of them cannot be read/found.
#10
I talked to catch, and we decided to move the md5 thing in another patch. Also, I removed the is readbale by the webserver, cause when the webserver can't read that file (and not fix it!), all is borked anyway. this is hopefully the final patch ;)
#11
I reviewed this in irc with Cornil, and tested manually. This last patch looks great to me.
Quick summary of the issue:
If you do $ mv default.settings.php settings.php drupal's installer simply fails with nasty warnings.
This patch ensures that the file exists in update_check_requirements() and allows you to install.
It's got a couple of interesting side-effects which we should deal with in the md5 followup patch.
So, if I do
$ mv default.settings.php settings.php$ cp settings.php default.settings.php
- the error message goes away and everything proceeds as normal.
If I do
$ mv default.settings.php settings.php$ touch default.settings.php
The error message goes away and I can install Drupal, but I get a settings.php with just the database connection information. That's what the md5 patch will attempt to deal with, I don't think we should concern ourselves about it here - since we're only helping people who aren't really following the instructions here anyway.
#12
I wouldn't think so lightly about this. The installation is part of the first impression new users get. If this fails the first impression won't be good, no matter whose fault it is.
#13
Well, the patch stops the installer from failing in this particular edge case. A side effect is that it also stops it from failing in sub-set of that edge case where we might not want it to - which is what the md5 of default.settings.php attempts to deal with. However, adding the md5 is a lot of extra work, and work that's easy to forget we need to do, every time we want to edit default.settings.php - so it seems sensible to break the patches up.
#14
But
'Please make sure that %default-file exists.'needs to read'Please ensure that %default-file is not modified in any way from the orginal download.'regardless.#15
here you go, I merged both sentences ;)
#16
#17
This patch no longer applies after #281446: Add 'status report' for installer requirements
#18
Also, the patch in #15 uses "orginal" rather than "original".
#19
i'll have a look at it soon, thanks for the report :)
#20
Patch completly redone in a way like the stuff from #281446: Add 'status report' for installer requirements
#21
Didn't worked for me. I renamed the file default.settings.php but did not get the requirements error. The problem was that the check was included in a condition, and only executed if a settings.php exists. The attached patch based on #20 fixes it.
#22
Would you mind exactly describing your problem? The check is executed in the conditional is sies/default directory exists, nothing else.
// Verify that the directory exists.if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
If you don't get the warning, please describe exactly what you did. In my opinion, still #20 should be valid
#23
I agree with @dropcube but if we move the $default_exists to just before the if why not just use the result of drupal_verify_install_file directly in the if condition? There is no use of the variable any further.
Change
<?php+ $default_exists = drupal_verify_install_file($default_settings_file, FILE_EXIST|FILE_READABLE);
+ if (!$default_exists) {
?>
To
<?php+ if (!drupal_verify_install_file($default_settings_file, FILE_EXIST|FILE_READABLE)) {
?>
#24
@CorniI: The first time I reviewed the patch I tested but didn't get the error report. Now I see that the check is executed in the conditional is sites/default directory exists.
Attached a new patch based on #20, adding some comments and cleaning up.
#25
Oops, there was a slash missing.
#26
Don't have enough time to test this patch thoroughly since I'm working on another patch, but I though I'd mention that with a fresh checkout I get both the "The settings file does not exist." and "The settings file is not writable." errors. I think the latter shouldn't be shown if the former is.
#27
@Xano, that was introduced with the new status report for the installer. webchick requested they be split in the issue, and I was planning to do the same with the files directory when some of the other installer cleanup patches are in.
#28
It's logical Drupal hasn't got permission if the file doesn't exist, but for novices this might be confusing, since they can see both errors as separate problems while in this case they are one.
#29
Xano, please open a separate issue for that if you think it's a problem.
#30
The last submitted patch failed testing.
#31
Duplicated effort of some sort over at http://drupal.org/node/208662
#32
Note that the current instructions are misleading anyway if you have already created a sites/example.org folder .
It says:
Copy the ./sites/example.org/default.settings.php file to ./sites/example.org/settings.php.but the code requires
./sites/default/default.settings.phpto exist. (I had removed the default directory as I didn't want any default).#33
That's why it says "copy". This means you will have to leave the original intact.
#34
@xano: read better #32. Even by copying (i.e. following the instructions to the letter), it fails in that specific configuration.
#35
So it doesn't count as renaming because you actually copied first, then deleted the original. But that's different from renaming, and is actually copying, even though the original was destroyed.
Hm.
I guess the lesson to be learned here is that yes,
if you delete configuration files that were distributed as part of the core of an application package just because you think you had no use for them then yes, unknown things can break.
[insert story here about uncle who decided he was tired of looking at that
boot.inifile - which he clearly never used...]Does the file have to be called
default.settings.php.do.not.delete.me?Those instructions do need to be worded more strongly, just to cover the cases of other things that people should NOT do when following the instructions.
Alternative wording suggestions welcome...
#36
I need to look at this more but I'm not so sure why we should be so dependent on a file that is seemingly a template in the first place. If you ask me a template configuration file is to be used once (on initial installation) and requiring default/default.settings.php when a settings.php is found is a bit overboard in the saneness checking.
#37
earnie, it needs to be re-used for multisite installations.
#38
If the need for default.settings.php is so great perhaps it needs to be moved to the system module folder. This would make it look less like an unimportant file that can be deleted.
#39
dman wrote:
I agree, but the problem here is that the file is named default.... and you are asked to copy it, indicating strongly that the default file is really just a sample. Sample config files are very common, and in all OS-es I have tried they can be removed without any side-effects what so ever.
Something has to be done with location/naming of that file - I agree with earnie on that.
Hans
PS! I normally like Drupal a lot and I use it for all classes I teach (at college), but that the installer (in Drupal 6.9) simply failed when I moved default.settings.php to settings.php, without any explanation, was a very bad experience - in front of my class. I and my 70 students found Drupal extremely stupid when we realized that it actually required the sample file to be present to work.
#40
Comment #9 gives the best advice here. There was no need for a patch just simply making sure I had a copy of settings.php and default.settings.php This fixed worked. Thanks!
#41
Resetting fields to more appropriate values. Unfortunately I can't revert the Assigned field to the previous value.
#42
I spoke with DamZ this weekend about this issue, and we should remove the default.settings.php copy step and just let it be rename. Which means that it doesn't have to check for default.settings.php and we just move the php settings and all that stuff in an other file or in the database.
#43
My opinion is that such things belong in a file in the system module.
#44
Marked #479006: Cannot rename sites/default/default.settings.php a duplicate of this bug. That is pure ugliness. I'd sure like to see this fixed.
#45
Beginner in comment #32 has a good point. He/she correctly identifies that the documentation instructs the installer to create a copy within the target directory (note that it doesn't say default directory). In a multi-site implementation I would suggest that using a "default" directory is not a best practice. By defining each of the domains, you better control risks associated with later installations. Consider the following environment:
(an established domain/directory)
(an established domain/directory)
(target directory containing original, unmodified default.settings.php and settings.php files)
Because the default.settings.php file must exist in the "sites/default" directory as required (hard coded) by line 176 of "includes/install.inc" ("$default_settings = './sites/default/default.settings.php';")(Drupal 6.12), the following must also exist:
(directory only containing original, unmodified default.settings.php file)
So besides the issue with the install not checking for the existence of the file, I propose that it isn't even looking for it in the correct place. It is searching outside of the scope defined by the installation in a multi-site environment. I have given thought to the process of creating all environments within a default directory that can be renamed to the correct site name but consider the following objective:
(an established domain/directory)
(target directory containing original, unmodified default.settings.php and settings.php files)
Starting the process by initially naming "sites/subdomain.mydomain.tld" as "sites/default" and running the install process has the unfortunate effect of going to the "sites/mydomain.tld" directory and the "sites/default" directory is never touched. The only way to mitigate this is to also rename the "sites/mydomain.tld" directory, thereby breaking that environment.
My suggestion would be to also change the "includes/install.inc" file to search for the file in the same location as the "settings.php" file. Perhaps with a change similar to the following:
- $default_settings = './sites/default/default.settings.php';
+ $default_settings = './' . conf_path(FALES, TRUE) . '/' . $prefix . default.settings.php';
$settings_file = './'. conf_path(FALSE, TRUE) .'/'. $prefix .'settings.php';
(Not sure how the "$prefix" variable is used so am not sure if it should be excluded.)
#46
With this patch, Drupal makes writes settings.php based on itself, without trying to use default.settings.php. This:
* allows mistakes in the workflow (you can either rename or copy default.settings.php)
* solves the issues described in #45
#47
What happens if you do touch sites/default/settings.php?
#48
Thanks for the contribution Damien (#46). I would agree that your suggestion would make more sense from a design perspective but I hadn't taken the leap to make the statement that default.settings.php was unnecessary in the overall flow. I would have thought that using a copy of this file, renamed to "settings.php" which would then be updated within the install process, would have sufficed. In fact this was how I thought it would have worked and resulted in early install failures until I noticed that you had to have both files.
Catch (#47), I'm not sure which senario you are referencing from your question. If you are asking about the one where installing a multisite instance for a subdomain, any objects in the "sites/default" directory will not be part of the process because of the cascading nature of directory selection found in the Drupal environment. The subdomain is tried first, followed by the main domain, before any default directory is tapped. If this isn't the question that you are asking please let us know.
#49
@james.tank - usually I install by creating an empty settings.php - i.e.
touch sites/default/settings.php- simply because it's less typing thancp sites/default/default.settings.php sites/default/settings.php.This is documented as an option in INSTALL.txt
You may do soby making a copy of default.settings.php (or create an empty file with
this name in the same directory).
I should probably just try it to see if it breaks, but about to head out.
#50
@catch - what you would want to test is having the default.settings.php file exist anywhere other than the "sites/default" directory. The install process will fail if "sites/default/default.settings.php" does not exist. In a multi-site environment, the "sites/default" directory may not be an available install location. The hard-coded requirement within the "includes/install.inc" file is what I would consider a bug.
#51
james.tank I'm aware of the original bug, just want to make sure there's no regressions elsewhere. I tested Damien's patch with an empty settings.php and still ended up with a proper settings.php afterwards, so no objections here.
#53
@catch: nothing should break in that case, you will just end up with a settings.php containing only the database credentials.
The only two ini_set() we have in default.settings.php are useless in most case, and we should move them out.
#54
And I should have read #51 before writing.
#55
The last submitted patch failed testing.
#56
I'm confused. What is the next step for this patch? Is the approach valid? (I originally came to this patch, because I did a mv instead of a copy, and I thought it should have given me a warning message that default.setting.php needed to be there.)
I dont understand why it failed the testbot.
I tried the patch on cvs, and it applies (with 3 line offset), and it installs with the patch [both when "copy" default.settings.php and when "mv/rename" default.settings.php.
I set to needs review to have the testbot try again. Maybe it was a testbot problem?
#57
The last submitted patch failed testing.
#58
Oh, slave #26. Why must you be so buggy?
#59
The last submitted patch failed testing.
#60
trying out a new testing bot that apparently wasn't working
#61
The last submitted patch failed testing.