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
- Write patch
- Test patch
- Commit
Comments
Comment #1
pere orgaThanks, 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;Comment #2
pere orgaPushed to 7.x-1.x.
Will release 1.1
Comment #3
pere orga