I just tried to install the latest HEAD version and got the following error message on http://localhost/d7test/install.php?q=install.php&profile=standard&local...

Warning: Invalid argument supplied for foreach() in Database::parseConnectionInfo()  (line 1463 of D:\www\d7test\includes\database\database.inc).

See the attached screenshot. Other info on that page:
Web server: Apache/2.2.11 (Win32) PHP/5.2.11
PHP: 5.2.11
PHP register globals: Disabled
PHP extensions: Enabled
Database support: Enabled
PHP memory limit: 128M
File system: Writable (public download method)
Unicode library: PHP Mbstring Extension
Settings file: The settings file does not exist.

After copying default.settings.php to settings.php, the installer continued to the next page. I suspect that the "Invalid argument..." warning was caused by the fact that settings.php was not present. However that error should not be shown because the overview already shows that "The settings file does not exist".

Comments

marcvangend’s picture

Priority: Normal » Critical
Issue tags: +Usability

By the way, I think this is critical, we should not ship with a huge usability WTF like this in the install process.

Crell’s picture

Hm. It should just be a matter of adding an if (is_array())) somewhere. Odd that it hasn't cropped up before. Agreed on the critical.

marcvangend’s picture

Yes, a simple if-statement should be enough. Unfortunately, I don't quite understand what's going on in parseConnectionInfo(), especially the part where it says if (!is_array(self::$databaseInfo)) { self::$databaseInfo = $databaseInfo; }.

I would add if (is_array($databaseInfo)) { right before the first foreach, but I'm not sure where to close the if-block.

  /**
   * Process the configuration file for database information.
   */
  final public static function parseConnectionInfo() {
    global $databases;

    _db_check_install_needed();

    $databaseInfo = $databases;
    foreach ($databaseInfo as $index => $info) {
      foreach ($databaseInfo[$index] as $target => $value) {
        // If there is no "driver" property, then we assume it's an array of
        // possible connections for this target. Pick one at random. That allows
        //  us to have, for example, multiple slave servers.
        if (empty($value['driver'])) {
          $databaseInfo[$index][$target] = $databaseInfo[$index][$target][mt_rand(0, count($databaseInfo[$index][$target]) - 1)];
        }
      }
    }

    if (!is_array(self::$databaseInfo)) {
      self::$databaseInfo = $databaseInfo;
    }

    // Merge the new $databaseInfo into the existing.
    // array_merge_recursive() cannot be used, as it would make multiple
    // database, user, and password keys in the same database array.
    else {
      foreach ($databaseInfo as $database_key => $database_values) {
        foreach ($database_values as $target => $target_values) {
          self::$databaseInfo[$database_key][$target] = $target_values;
        }
      }
    }
  }
yoroy’s picture

subscribe :)

marcvangend’s picture

Yoroy (and everybody else): also see #753764: Duplicate and incorrect error messages during install, which is not about the php causing this error, but about the stunning ugliness and confusing messages on this page.

Garrett Albright’s picture

Status: Active » Needs review
StatusFileSize
new701 bytes

This seems to fix it.

Garrett Albright’s picture

StatusFileSize
new1.89 KB

Hmm… While I'm at it, is it proper that we're using camelCase for $databaseInfo here when it's not an object property? Here's another patch which fixes that if not.

aspilicious’s picture

#6 and #7 are fine and will kill the warning, I don't know which one follows standards

Crell’s picture

Status: Needs review » Needs work

I believe Garrett is correct. #7 it is. Passes bot, looks right to me, with one exception. The first foreach() indentation is messed up for some reason.

Garrett, please fix that and repost, and just set it to RTBC. Let's just get this resolved. :-) Thanks!

Garrett Albright’s picture

Crell, sorry, but I don't see any difference in indentation… Can anyone else see it?

Crell’s picture

Maybe it's a tab character? The first foreach was indented an extra few spaces when I looked at the patch in my browser.

marcvangend’s picture

+++ includes/database/database.inc	26 Mar 2010 17:26:04 -0000
@@ -1459,27 +1459,27 @@
     // Merge the new $databaseInfo into the existing.

Shouldn't this be changed to "Merge the new $database_info into the existing."?

Crell’s picture

Ahso. Yes it should be. Good catch!

EvanDonovan’s picture

Patch #7 fixes the error for me. Can someone please re-roll with the code style fix? As one who often forgets to do that default.settings.php -> settings.php step, this was freaky to me.

yoroy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.89 KB

Fixing the comment as pointed out in #12. Didn't see anything wrong with the indentation.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, I also can't see an indentation issue here.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 753754-15.patch, failed testing.

aspilicious’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.86 KB

Lets try this

aspilicious’s picture

StatusFileSize
new1.92 KB

Oops this one is better (hopefully)

Crell’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.8 KB

#19 is missing the fix that this thread is actually for. :-) Someone mark this RTBC please.

Status: Needs review » Needs work

The last submitted patch, 753754-20.patch, failed testing.

Crell’s picture

Status: Needs work » Needs review
StatusFileSize
new1.8 KB

Bah, stupid git!

Status: Needs review » Needs work

The last submitted patch, 753754-databaseInfo.patch, failed testing.

Crell’s picture

Status: Needs work » Needs review

This applies just fine for me. Bot, you're a liar!

Garrett Albright’s picture

StatusFileSize
new1.89 KB

Maybe it doesn't like the stuff Git is adding in the header. (Trying to apply the patch with patch didn't work for me either.) Here's one made with CVS.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD.

marcvangend’s picture

Status: Fixed » Needs review
StatusFileSize
new734 bytes

It looks like the patch from #19 was committed, which does contain some good changes, but not the bugfix this issue was all about in the first place (as crell also mentioned in #20). Here is a follow-up.

aspilicious’s picture

Yeah I forgot the bugfix...
if #19 is committed #27 needs to be committed to

catch’s picture

Status: Needs review » Reviewed & tested by the community
dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

farneville’s picture

StatusFileSize
new56.77 KB

I am not sure if I am having the same issues as the others have posted here but can please someone take a look if it's related.

I am trying to test drupal and decided to install it locally on my machine but upon installation I got the attached error it is saying that settings.php does not exists on ./sites/default/ but I am certain that it is there. Any help would be appreciated...

marcvangend’s picture

@farneville: That is not what this issue is about. I advise you to search for another topic that is related, or else start a new one.

Richard Barry’s picture

Version: 7.x-dev » 7.0-alpha6
Component: database system » other
Status: Closed (fixed) » Active

I tried to install Drupal 7 on Win 7 (32) Prof using WAMP 2.0i and I get a pink warning "Default settings file The default settings file does not exist. The Drupal installer requires that the ./sites/default/default.settings.php file not be modified in any way from the original download. "

Followed by (in green)

Settings file The ./sites/default/settings.php file exists.
Settings file Settings file is writable.

Frustrating and inconsistent.....

If this issue has been fixed, suggest that this thread gets a link to the fix page.

marcvangend’s picture

Version: 7.0-alpha6 » 7.x-dev
Status: Active » Closed (fixed)

Richard, that is not what this issue was about. I suspect that you renamed default.settings.php to settings.php, while you are supposed to copy it. If the information provided by the installer was frustrating, inconsistent, or otherwise not good enough for you, please open a new issue to improve that (I'll help if you send me the link). Your usability feedback is very welcome.

Richard Barry’s picture

Thanks - fixing the "default.settings.php to settings.php" issue got me past that problem.