Updated: Comment #N

Problem/Motivation

If the database parameters entered become invalid, the Drupal site will fail to load and instead return the SQL error below:

PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (4) in moodle_connector_connect() (line 78 of /path/to/drupal/sites/all/modules/contrib/moodle_connector/moodle_connector.module).

I ran into this error when moving a site between dev environments. Due to the error, drush cannot be used to update the variables storing the database parameters. You also cannot clear the cached variable values via drush. This requires the variables to be update and the cache tables to be truncated manually.

Proposed resolution

The site should fail gracefully and log an error via watchdog if the database parameters are invalid, allowing the site to continue to function.

Remaining tasks

  1. Write patch
  2. Test patch
  3. Commit

Comments

pere orga’s picture

Status: Active » Needs work

Thanks, you are right, this should be fixed. I'm going to catch the exception.

Another way of resetting the variable (that should disable moodle conntector without killing the site) is via the settings.php file:
$conf['moodle_connector_db_server'] = FALSE;

pere orga’s picture

Pushed to 7.x-1.x.

Will release 1.1

pere orga’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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