Index: devel.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/devel/devel.module,v retrieving revision 1.106.4.101 diff -u -r1.106.4.101 devel.module --- devel.module 9 Oct 2008 03:08:28 -0000 1.106.4.101 +++ devel.module 2 Mar 2009 16:19:34 -0000 @@ -234,7 +234,13 @@ * behavior when stepping though in a debugger. */ function devel_init() { - if (strstr($_SERVER['PHP_SELF'], 'update.php') || strstr($_GET['q'], 'autocomplete') || $_GET['q'] == 'admin/content/node-settings/rebuild' || $_GET['q'] == 'upload/js' || substr($_GET['q'], 0, strlen('system/files')) == 'system/files') { + $db_type = substr($GLOBALS['db_url'], 0, strpos($GLOBALS['db_url'], '://')); + if (in_array($db_type, array('mysql', 'mysqli')) && !variable_get('dev_sql_mode_server_default', 1)) { + $sql_modes = implode(',', variable_get('dev_sql_mode_override', array())); + db_query("SET SESSION sql_mode='%s'", array($sql_modes)); + } + + if (strstr($_SERVER['PHP_SELF'], 'update.php') || strstr($_GET['q'], 'autocomplete') || $_GET['q'] == 'admin/content/node-settings/rebuild' || $_GET['q'] == 'upload/js' || substr($_GET['q'], 0, strlen('system/files')) == 'system/files') { // update.php relies on standard error handler. avoid breaking a few other pages. } else { @@ -718,6 +724,65 @@ '#size' => 4, '#description' => t('If storing query statistics, only store every nth page view. 1 means every page view, 2 every second, and so on.')); + $db_type = substr($GLOBALS['db_url'], 0, strpos($GLOBALS['db_url'], '://')); + if (in_array($db_type, array('mysql', 'mysqli'))) { + $sql_modes = drupal_map_assoc( + array( + 'ANSI', + 'STRICT_TRANS_TABLES', + 'TRADITIONAL', + 'ALLOW_INVALID_DATES', + 'ANSI_QUOTES', + 'ERROR_FOR_DIVISION_BY_ZERO', + 'HIGH_NOT_PRECEDENCE', + 'IGNORE_SPACE', + 'NO_AUTO_CREATE_USER', + 'NO_AUTO_VALUE_ON_ZERO', + 'NO_BACKSLASH_ESCAPES ', + 'NO_DIR_IN_CREATE', + 'NO_ENGINE_SUBSTITUTION', + 'NO_FIELD_OPTIONS', + 'NO_KEY_OPTIONS', + 'NO_TABLE_OPTIONS', + 'NO_UNSIGNED_SUBTRACTION', + 'NO_ZERO_DATE', + 'NO_ZERO_IN_DATE', + 'ONLY_FULL_GROUP_BY', + 'PIPES_AS_CONCAT', + 'REAL_AS_FLOAT', + 'STRICT_ALL_TABLES', + 'DB2', + 'MAXDB', + 'MSSQL', + 'MYSQL323', + 'MYSQL40', + 'ORACLE', + 'POSTGRESQL' + ) + ); + asort($sql_modes, SORT_STRING); + $form['sql_mode'] = array( + '#type' => 'fieldset', + '#title' => t('SQL Mode'), + '#description' => t('Switch the SQL mode supported by MySQL.'), + '#collapsible' => FALSE + ); + $form['sql_mode']['dev_sql_mode_server_default'] = array( + '#type' => 'checkbox', + '#title' => t('Use server default'), + '#default_value' => variable_get('dev_sql_mode_server_default', 1), + '#description' => t('Enabling this option ignores any SQL mode selections') + ); + $form['sql_mode']['dev_sql_mode_override'] = array( + '#type' => 'select', + '#title' => t('SQL modes to enable'), + '#options' => $sql_modes, + '#multiple' => TRUE, + '#size' => 6, + '#default_value' => variable_get('dev_sql_mode_override', array()) + ); + } + $form['dev_timer'] = array('#type' => 'checkbox', '#title' => t('Display page timer'), '#default_value' => variable_get('dev_timer', 0),