Index: branches/unlabeled/unlabeled-1.65.2/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -r7660 -r7816 --- branches/unlabeled/unlabeled-1.65.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 7660) +++ branches/unlabeled/unlabeled-1.65.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 7816) @@ -356,26 +356,46 @@ $tablename = $config['TableName']; $conn =& $this->Application->GetADODBConnection(); + + $table_found = $conn->Query('SHOW TABLES LIKE "'.$tablename.'"'); + if (!$table_found) { + // config present, but table missing, strange + $debugger->appendHTML("Config Warning: Table $tablename missing, but prefix ".$config['Prefix']." requires it!"); + safeDefine('DBG_RAISE_ON_WARNINGS', 1); + return ; + } + $res = $conn->Query("DESCRIBE $tablename"); foreach ($res as $field) { $f_name = $field['Field']; if (getArrayValue($config, 'Fields')) { - if ( !array_key_exists ($f_name, $config['Fields']) ) { - $debugger->appendHTML("Config Warning: Field $f_name exists in the database, but is not defined in config file for prefix ".$config['Prefix']."!"); + if (!array_key_exists ($f_name, $config['Fields'])) { + $debugger->appendHTML("Config Warning: Field $f_name exists in the database, but is not defined in config file for prefix ".$config['Prefix']." !"); safeDefine('DBG_RAISE_ON_WARNINGS', 1); } else { $options = $config['Fields'][$f_name]; - if ($field['Null'] == '') { + if ($field['Null'] != 'YES') { + // MySQL5 for null returns "NO", but MySQL4 returns "" if ( $f_name != $config['IDField'] && !isset($options['not_null']) && !isset($options['required']) ) { - $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is NOT NULL in the database, but is not configured as not_null or required!"); + $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is NOT NULL in the database, but is not configured as not_null or required !"); safeDefine('DBG_RAISE_ON_WARNINGS', 1); } if ( isset($options['not_null']) && !isset($options['default']) ) { - $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is described as NOT NULL, but does not have DEFAULT value!"); + $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is described as NOT NULL, but does not have DEFAULT value !"); safeDefine('DBG_RAISE_ON_WARNINGS', 1); } + + if (!isset($options['default'])) { + $debugger->appendHTML("Config Error: Default value for field $f_name in config for prefix ".$config['Prefix']." not set !"); + safeDefine('DBG_RAISE_ON_WARNINGS', 1); + } + else if ($options['default'] != '#NOW#' && $field['Default'] !== (string)$options['default']) { + $debugger->appendHTML("Config Error: Default value for field $f_name (".$options['default'].") in config for prefix ".$config['Prefix']." differs from default value from field in database (".$field['Default'].") !"); + $debugger->dumpVars($field['Default'], $options['default'], 'STRICT'); + safeDefine('DBG_RAISE_ON_WARNINGS', 1); + } } }