Index: database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/database.inc,v retrieving revision 1.57 diff -u -r1.57 database.inc --- database.inc 1 Jul 2009 08:11:27 -0000 1.57 +++ database.inc 2 Jul 2009 21:17:59 -0000 @@ -2460,6 +2460,35 @@ } /** + * Helper function to get duration lag from variable + * and set the session variable that contains the lag. + */ +function db_ignore_slave() { + $use_slave = &drupal_static(__FUNCTION__); + // This statement will only be executed the first time through when $use_slave + // is NULL, since it will be set to TRUE or FALSE at the end. + if ($use_slave == NULL) { + $connection_info = Database::getConnectionInfo(); + // Only set ignore_slave_server if there are slave servers + // being used, which is assumed if there are more than one. + if (count($connection_info) > 1) { + // Five minutes is long enough to allow the slave to break and resume + // interrupted replication without causing problems on the Drupal site + // from the old data. + $duration = variable_get('maximum_replication_lag', 300); + // Set session variable with amount of time to delay before using slave. + $_SESSION['ignore_slave_server'] = REQUEST_TIME + $duration; + // Set cached variable to true to indicate that slave is being used. + $use_slave = TRUE; + } + else { + // Set cached variable to false since there is no slave being used. + $use_slave = FALSE; + } + } +} + +/** * @ingroup database-legacy * * These functions are no longer necessary, as the DatabaseStatementInterface interface @@ -2688,19 +2717,5 @@ } /** - * Helper function to get duration lag from variable - * and set the session variable that contains the lag. - */ -function db_ignore_slave() { - // Five minutes is long enough to allow the slave to break and resume - // interrupted replication without causing problems on the Drupal site - // from the old data. - $duration = variable_get('maximum_replication_lag', 300); - - // Set session variable with amount of time to delay before using slave. - $_SESSION['ignore_slave_server'] = REQUEST_TIME + $duration; -} - -/** * @} End of "ingroup database-legacy". */