diff --git a/commerce.install b/commerce.install index 03f4dbc..941ffd3 100644 --- a/commerce.install +++ b/commerce.install @@ -323,3 +323,33 @@ function commerce_update_7102() { ->execute(); return t('The module weight for Commerce has been increased.'); } + +/** + * Implements hook_requirements(). + */ +function commerce_requirements($phase) { + $requirements = array(); + // Ensure translations don't break at install time. + $t = get_t(); + + if ($phase === 'runtime') { + // Check database transaction isolation level. + $results = db_query("SELECT variable_value IsolationLevel + FROM information_schema.session_variables + WHERE variable_name = 'tx_isolation' + ")->fetchAssoc(); + $iso_level = reset($results); + if (strcasecmp($iso_level, 'READ-COMMITTED') !== 0) { + $requirements['commerce_tx_iso'] = array( + 'title' => $t('Commerce Performance'), + 'severity' => REQUIREMENT_INFO, + 'value' => $t('Transaction Isolation Level: @value', array('@value' => $iso_level)), + 'description' => $t('Drupal can suffer from deadlock issues related to fields that effects Commerce a lot, for the best database performance, set the transaction isolation level to READ-COMMITTED. Inside settings.php add this below the $databases array

@line

.', array( + '@line' => '$databases[\'default\'][\'default\'][\'init_commands\'][\'isolation\'] = "SET SESSION tx_isolation=\'READ-COMMITTED\'";', + )), + ); + } + } + + return $requirements; +} \ No newline at end of file