When upgrading a site, as from Drupal 6 to Drupal 7, if settings.php has not had the database information set in it, update.php gives this (in this case) incorrect and highly misleading error message:

A PDO database driver is required!

You need to enable the PDO_ database driver for PHP 5.2.0 or higher so that Drupal 7 can access the database.

See the system requirements page for more information.

For more background on the confusion caused by this message, see the question and the noted need of this error message to be greatly improved mentioned in support request #862682: Upgrade from d6 -> d7a6 results in PDO error: "A PDO database driver is required".

(Aside: Has the usability of the empty database array in settings.php, versus one filled with mock data, been discussed? I think mock data for the default case would be much easier to start with; i kept one to copy/paste.)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhedstrom’s picture

Jeff Veit’s picture

Ditto. Happened to me too when I mistakenly thought I'd saved the settings.php file.

webchick’s picture

Priority: Major » Critical

I'm going to go ahead and bump this to critical. Drupal giving just plain wrong error messages that will actively prevent someone from installing/updating it, are release blockers IMO.

bjaspan’s picture

Wow. I was going to ask, "Does this bug really make D7 useless?" but apparently Angie thinks it does and far be it from me to question her. :-)

catch’s picture

Status: Active » Needs review
FileSize
2.8 KB

I also think this isn't critical, the only way to get here is to not follow the upgrade instructions at all. Here's an untested patch for it though.

Sivaji_Ganesh_Jojodae’s picture

+    else {
+      print '<h2>There is no database connection information available. Copy the $db_url variable from your Drupal 6 settings.php file to your Drupal 7 installation, then try again.</h2>';
+      exit();

Is it correct ?

$db_url in d7 is

 * Database configuration format:
 * @code
 *   $databases['default']['default'] = array(
 *     'driver' => 'mysql',
 *     'database' => 'databasename',
 *     'username' => 'username',
 *     'password' => 'password',
 *     'host' => 'localhost',
 *     'prefix' => '',
 *   );
 *   $databases['default']['default'] = array(
 *     'driver' => 'pgsql',
 *     'database' => 'databasename',
 *     'username' => 'username',
 *     'password' => 'password',
 *     'host' => 'localhost',
 *     'prefix' => '',
 *   );
 *   $databases['default']['default'] = array(
 *     'driver' => 'sqlite',
 *     'database' => '/path/to/databasefilename',
 *   );
 * @endcode

In d6 it is

 * Database URL format:
 *   $db_url = 'mysql://username:password@localhost/databasename';
 *   $db_url = 'mysqli://username:password@localhost/databasename';
 *   $db_url = 'pgsql://username:password@localhost/databasename';
catch’s picture

@sivaji - it's correct because the hunk just above this one translates the Drupal 6 format to the Drupal 7 one.

Stevel’s picture

Status: Needs review » Needs work

We should also mention $db_prefix in the message, as copying only $db_url when $db_prefix was set could result in some serious trouble (e.g. a site that has '' (no prefix) and 'staging_' as prefixes).

catch’s picture

Not sure what the text should be, this is the relevant bit from UPGRADE.txt:


8.  Copy your backed up "files" and "sites" directories to the Drupal
    installation directory. If other system files such as .htaccess or
    robots.txt were customized, re-create the modifications in the new
    versions of the files using the backups taken in step #1.

The instructions here are to copy the D6 settings.php directly into the D7 installation, which isn't what I'd do personally, since settings.php changes between major versions, and I'd rather have the new documented variables available to me.

So first, I think we should just point people to upgrade.txt

Second, I don't like the instructions that are in upgrade.txt, and they certainly aren't great for explaining what to do to people who find themselves in this situation.

LaurentAjdnik’s picture

Tagging

catch’s picture

Status: Needs work » Postponed
FileSize
2.76 KB

Here's one that just points to UPGRADE.txt, I am tempted to mark this issue postponed on #295255: Clean-up the upgrade path: UPGRADE.txt, in fact I'm going to do that now and bump that to critical.

David_Rothstein’s picture

+      print '<h2>There is no database connection information available in settings.php. Follow the instructions in UPGRADE.txt to proceed.</h2>';
+      exit();

Instead of doing this, I think we should just add it via update_extra_requirements() instead, so they get it as part of the nice pretty status report. (We could add a condition on the PDO driver check later to make sure it doesn't also trigger.)

If you do leave your site without database connection info in settings.php for more than a very short amount of time it's kind of a weird state to be in. (For one thing, wouldn't anyone visiting the site get redirected to install.php and be able to start going through the installer, and in some cases, e.g. a server with no root password, maybe even be able to perform a successful installation?) But I guess we do have to cater to it somehow.

catch’s picture

I reckon you could install on a server with sqlite pretty easily, only needs a writable file path to create a new database and no password.

webchick’s picture

Issue tags: +beta blocker

This has also hit a few people so I'd like to fix it before the next beta.

effulgentsia’s picture

Status: Postponed » Needs review

Un-postponing, because webchick gave #295255: Clean-up the upgrade path: UPGRADE.txt the "beta blocker" tag, so let's assume that by the next beta (which is all we need to worry about in regards to update procedures), we'll have an UPGRADE.txt file that doesn't give people the wrong installation steps, and that therefore, can be referred to.

I think #11 is an adequate solution, so +1 from me on that.

#12 may be an improvement, but unless someone feels inspired to roll that patch very soon, let's go with #11, and then have a separate issue (would it really justify a priority greater than "normal"?) to make improvements.

webchick’s picture

Well. While I'm all about the problem getting fixed ASAP, David's right that the current way is very non-Drupal and skirting our established mechanisms for this. Over at #722974: Install script returns a blank page for PHP4, PHP 5.1 (should display *something* instead) we have to do it that way, because the alternative is fatal errors. But here I think we should use the standard hook_requirements() mechanism, if we can.

effulgentsia’s picture

Status: Needs review » Needs work

David indicated he thinks he can roll a patch for #12 later today. If he doesn't get to it, I'll do it.

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
3.75 KB

Looks like I was wrong. We can't do the normal requirements check (at least not at all easily) because in the normal workflow we'd have to bootstrap the database before that, which we can't do here...

So instead, this is pretty much just the same as the above patch, with a few small cleanups.

catch’s picture

Status: Needs review » Needs work
FileSize
1011 bytes

No need for a new message because when the original bug is fixed we redirect to install.php anyway, which has been the case for several releases now.

catch’s picture

Status: Needs work » Needs review
catch’s picture

FileSize
1.52 KB

My patch with David's comment.

edit: actually I changed from the !empty() to the isset as well, so it's all David's patch with the attempt to print a message just ripped out.

Status: Needs review » Needs work
Issue tags: -beta blocker

The last submitted patch, 887288.patch, failed testing.

catch’s picture

Status: Needs work » Needs review
Issue tags: +beta blocker

#22: 887288.patch queued for re-testing.

Somehow I don't think this broke the filter formats access test.

mlncn’s picture

Status: Needs review » Reviewed & tested by the community

Very nice– prevents the misleading error if i put a string or something into the $databases variable, and prints the more correct error instead:

DatabaseConnectionNotDefinedException: The specified database connection is not defined: default in Database::openConnection() (line 1522 of /home/ben/workspace/d7x/includes/database/database.inc).

Haven't tested this against an upgrade situation but any issues there will probably be addressed in #949102: Polish UPGRADE.txt.

Thanks Catch, David!

David_Rothstein’s picture

FileSize
1.31 KB

Hm, I guess it is not so bad just doing that. Redirecting to install.php is pretty weird, but it does appear to be the case that the same thing would have happened in previous Drupal versions.

There was an extra "`" character in the code comment and there shouldn't be a space before it, because the elseif() is related to the previous clause. Fixed in the attached - still RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great. Committed #26 to HEAD. Nice work, folks!

Status: Fixed » Closed (fixed)
Issue tags: -beta blocker

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