Install fails when default.settings.php is not present

CorniI - September 23, 2008 - 08:45
Project:Drupal
Version:7.x-dev
Component:install system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Issue tags:DrupalWTF
Description

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...

AttachmentSizeStatusTest resultOperations
installpatch.patch642 bytesIdleFailed: Failed to install HEAD.View details | Re-test
installpatch.patch1.02 KBIdleFailed: Failed to apply patch.View details | Re-test

#1

Dave Reid - September 23, 2008 - 16:27

That's weird. What files do you have listed in the sites folder of your drupal install?

#2

CorniI - September 23, 2008 - 19:30
Title:Install failes after entering DB credentials» Install failes when default.settings.php is not present
Assigned to:Anonymous» CorniI

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

Dave Reid - September 23, 2008 - 19:35
Title:Install failes when default.settings.php is not present» Install fails when default.settings.php is not present

Fixed title spelling error. Once you get your patch written, I'll help test!

#4

CorniI - September 24, 2008 - 07:57
Priority:critical» normal
Status:active» postponed

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

CorniI - September 27, 2008 - 10:01
Status:postponed» needs review

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.

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile.patch2.72 KBIdleFailed: Failed to apply patch.View details | Re-test

#6

earnie@drupal.org - September 27, 2008 - 14:06
Status:needs review» needs work

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

CorniI - September 27, 2008 - 14:44

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...

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile.patch2.99 KBIdleFailed: Failed to apply patch.View details | Re-test

#8

CorniI - September 27, 2008 - 14:54
Status:needs work» needs review

no comment -.-

#9

Xano - September 27, 2008 - 23:04
Status:needs review» needs work

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:

  • The Drupal installer requires that you create a settings file as part of the installation process.
    1. Copy the ./sites/default/default.settings.php file to ./sites/default/settings.php.
    2. Change file permissions so that it is writable by the web server. If you are unsure how to grant file permissions, please consult the on-line handbook.
    3. More details about installing Drupal are available in INSTALL.txt.

  • Please make sure that ./sites/default/default.settings.php exists and is readable by the webserver.

After:

  • The Drupal installer requires that you create a settings file as part of the installation process. Copy the ./sites/default/default.settings.php file to ./sites/default/settings.php.
  • Please make sure that ./sites/default/default.settings.php exists and is readable by the webserver.
  • Change $file permissions so that it is writable by the web server. If you are unsure how to grant file permissions, please consult the on-line handbook. More details about installing Drupal are available in INSTALL.txt.

$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

CorniI - September 28, 2008 - 11:38
Status:needs work» needs review

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 ;)

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile.patch2.69 KBIdleFailed: Failed to apply patch.View details | Re-test

#11

catch - September 28, 2008 - 12:04
Status:needs review» reviewed & tested by the community

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

Xano - September 28, 2008 - 12:22

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

catch - September 28, 2008 - 12:32

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

earnie - September 28, 2008 - 17:03
Status:reviewed & tested by the community» needs work

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

CorniI - September 28, 2008 - 17:25
Status:needs work» needs review

here you go, I merged both sentences ;)

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile.patch2.74 KBIdleFailed: Failed to apply patch.View details | Re-test

#16

earnie - September 28, 2008 - 17:28
Status:needs review» reviewed & tested by the community

#17

dropcube - October 1, 2008 - 15:54
Status:reviewed & tested by the community» needs work

This patch no longer applies after #281446: Add 'status report' for installer requirements

#18

keith.smith - October 1, 2008 - 22:04

Also, the patch in #15 uses "orginal" rather than "original".

#19

CorniI - October 2, 2008 - 14:41

i'll have a look at it soon, thanks for the report :)

#20

CorniI - October 2, 2008 - 20:18
Status:needs work» needs review

Patch completly redone in a way like the stuff from #281446: Add 'status report' for installer requirements

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile2.patch2.9 KBIdleFailed: Failed to apply patch.View details | Re-test

#21

dropcube - October 3, 2008 - 01:18

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.

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile-312144-21.patch2.82 KBIdleFailed: Failed to apply patch.View details | Re-test

#22

CorniI - October 3, 2008 - 09:05

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

earnie - October 3, 2008 - 11:31
Status:needs review» needs work

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

dropcube - October 3, 2008 - 14:06
Status:needs work» needs review

@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.

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile-312144-24.patch2.01 KBIdleFailed: Failed to apply patch.View details | Re-test

#25

dropcube - October 3, 2008 - 20:13

Oops, there was a slash missing.

AttachmentSizeStatusTest resultOperations
install_check_for_defaultsettingsfile-312144-25.patch2.01 KBIdleFailed: Failed to apply patch.View details | Re-test

#26

Xano - October 8, 2008 - 15:28

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

catch - October 8, 2008 - 15:53

@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

Xano - October 8, 2008 - 17:06

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

catch - October 8, 2008 - 18:36

Xano, please open a separate issue for that if you think it's a problem.

#30

Anonymous (not verified) - November 12, 2008 - 08:20
Status:needs review» needs work

The last submitted patch failed testing.

#31

dman - November 12, 2008 - 08:47

Duplicated effort of some sort over at http://drupal.org/node/208662

#32

beginner - November 23, 2008 - 04:19

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.php to exist. (I had removed the default directory as I didn't want any default).

#33

Xano - November 23, 2008 - 12:09

That's why it says "copy". This means you will have to leave the original intact.

#34

beginner - November 24, 2008 - 01:02

@xano: read better #32. Even by copying (i.e. following the instructions to the letter), it fails in that specific configuration.

#35

dman - November 24, 2008 - 02:09

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.ini file - 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.

Copy the file. Do not rename it. Copy it. Leave the original default/default.settings.php where it was. Do not delete it after successfully copying. Do not rename it. Do not move it into another place. Do not delete any file that was originally distributed with Drupal. Do not rename them either. Do not wave a big magnet over your hard drive. Do not pour honey into the drive slot.

Alternative wording suggestions welcome...

#36

earnie - November 24, 2008 - 12:51

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

Dave Reid - January 6, 2009 - 14:48

earnie, it needs to be re-used for multisite installations.

#38

earnie - January 6, 2009 - 17:27

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

hansfn - January 22, 2009 - 00:32

dman wrote:

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.

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

topper910 - March 30, 2009 - 03:03
Version:7.x-dev» 6.2
Assigned to:CorniI» topper910

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

earnie - March 30, 2009 - 03:14
Version:6.2» 7.x-dev
Assigned to:topper910» Anonymous

Resetting fields to more appropriate values. Unfortunately I can't revert the Assigned field to the previous value.

#42

Bojhan - April 27, 2009 - 10:52

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

earnie - April 27, 2009 - 11:27

My opinion is that such things belong in a file in the system module.

#44

webchick - June 1, 2009 - 20:03

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

james.tank - June 3, 2009 - 18:24

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:

  • sites/mydomain.tld
    (an established domain/directory)
  • sites/yourdomain.tld
    (an established domain/directory)
  • sites/newdomain.tld
    (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:

  • sites/default
    (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:

  • sites/mydomain.tld
    (an established domain/directory)
  • sites/subdomain.mydomain.tld
    (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

Damien Tournoud - June 7, 2009 - 04:20
Status:needs work» needs review

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

AttachmentSizeStatusTest resultOperations
312144-default-settings-php.patch1.44 KBIdleFailed: Failed to apply patch.View details | Re-test

#47

catch - June 10, 2009 - 16:38

What happens if you do touch sites/default/settings.php?

#48

james.tank - June 10, 2009 - 16:55

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

catch - June 10, 2009 - 17:00

@james.tank - usually I install by creating an empty settings.php - i.e. touch sites/default/settings.php - simply because it's less typing than cp sites/default/default.settings.php sites/default/settings.php.

This is documented as an option in INSTALL.txt

You may do so
   by 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

james.tank - June 13, 2009 - 05:48

@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

catch - June 13, 2009 - 09:48

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

Damien Tournoud - June 23, 2009 - 00:23

@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

Damien Tournoud - June 23, 2009 - 00:25

And I should have read #51 before writing.

#55

System Message - June 24, 2009 - 01:25
Status:needs review» needs work

The last submitted patch failed testing.

#56

YesCT - June 25, 2009 - 03:23
Status:needs work» needs review

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

System Message - June 28, 2009 - 03:55
Status:needs review» needs work

The last submitted patch failed testing.

#58

webchick - June 28, 2009 - 04:02
Status:needs work» needs review

Oh, slave #26. Why must you be so buggy?

#59

System Message - July 24, 2009 - 04:10
Status:needs review» needs work

The last submitted patch failed testing.

#60

deekayen - July 24, 2009 - 04:12
Status:needs work» needs review

trying out a new testing bot that apparently wasn't working

#61

System Message - July 28, 2009 - 22:45
Status:needs review» needs work

The last submitted patch failed testing.

 
 

Drupal is a registered trademark of Dries Buytaert.