After transferring our site to another server, we were unable to access to Drupal. Every time we tried to load our site we received a Drupal error page that stated, "Unable to connect to database server".

With some research, we found that the problem was "drupalvb_db" in the variable table in our Drupal database. Drupal vB seems to hardcode the MySQL connection string and store it in the database. However if Drupal is moved to another server with a different connection string, the site does not work.

I would think DB connection strings should not be stored in the database, especially ones that cause the site to crash.

Comments

sun’s picture

Version: 5.x-2.0-beta1 » 5.x-2.0-rc1

That should not happen. I'll try to come up with a patch.

sun’s picture

Assigned: Unassigned » sun
Status: Active » Needs review
StatusFileSize
new3.36 KB

Since Drupal's current database layer does not provide a separate function to check a database connection without displaying a maintenance page, this patch needs to implement custom connection checks into Drupal vB.

Please test.

sun’s picture

Status: Needs review » Fixed

Thanks, committed.

sgdev’s picture

I hadn't tested it out yet ... was going to do so shortly. Not sure how this was ready to be committed without testing?

sun’s picture

I tested this patch myself. It not only fixed this bug, but also increased performance of Drupal vB.
Feel free to re-open this issue if you still encounter this bug.

sgdev’s picture

After I transferred the site to our secondary server, I was able to log in but I received lots of errors. One of the errors said Drupal vB was not referencing the right database and I needed to change it. I made the change and the errors went away. I just wanted to verify that this is the expected functionality?

sun’s picture

Status: Fixed » Needs review
StatusFileSize
new714 bytes

There should be exactly one error message from Drupal vB if the database connection to vB is not valid, including a link to Drupal vB's database settings to fix it.

Heck, your mention of "log in" revealed that implementation of hook_user() does not yet check whether the database connection is valid.

sun’s picture

StatusFileSize
new1.12 KB

Another one bites in the dust...

sgdev’s picture

Just so I understand, the patch in #8 replaces the one in #7?

sun’s picture

Yes, patch in #8 includes all necessary changes.

sun’s picture

Reviews, tests, anyone?

sgdev’s picture

Sorry I haven't had the need to transfer the site in the past few days. I have been working on handling other Drupal issues. I might have the chance to do so before long. I will let you know if I do.

sun’s picture

Status: Needs review » Fixed

Sorry, 5.x-2.0 needs to be released. These checks work as claimed at least for me. If there are some more missing at another point, we can add them later.

Committed, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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