Index: trunk/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -N -r7991 -r7996
--- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 7991)
+++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 7996)
@@ -376,7 +376,15 @@
$res = $conn->Query("DESCRIBE $tablename");
$config_link = $debugger->getFileLink(FULL_PATH.$this->prefixFiles[$config['Prefix']], 1, $config['Prefix']);
-
+
+ $error_messages = Array (
+ 'field_not_found' => 'Config Warning: Field %s exists in the database, but is not defined in config file for prefix %s !',
+ 'default_missing' => 'Config Error: Default value for field %s in config for prefix %s not set !',
+ 'not_null_error1' => 'Config Error: Field %s in config for prefix %s is NOT NULL in the database, but is not configured as not_null or required !',
+ 'not_null_error2' => 'Config Error: Field %s in config for prefix %s is described as NOT NULL, but does not have DEFAULT value !',
+ 'invalid_default' => 'Config Error: Default value for field %s%s (%s) in config for prefix %s differs from default value from field in database (%s) !',
+ );
+
foreach ($res as $field) {
$f_name = $field['Field'];
if (getArrayValue($config, 'Fields')) {
@@ -386,43 +394,40 @@
}
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_link." !");
+ $debugger->appendHTML(sprintf($error_messages['field_not_found'], $f_name, $config_link));
safeDefine('DBG_RAISE_ON_WARNINGS', 1);
}
else {
$options = $config['Fields'][$f_name];
$default_missing = false;
if (!array_key_exists('default', $options)) {
- $debugger->appendHTML("Config Error: Default value for field $f_name in config for prefix ".$config_link." not set !");
+ $debugger->appendHTML(sprintf($error_messages['default_missing'], $f_name, $config_link));
safeDefine('DBG_RAISE_ON_WARNINGS', 1);
$default_missing = true;
}
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_link." is NOT NULL in the database, but is not configured as not_null or required !");
+ $debugger->appendHTML(sprintf($error_messages['not_null_error1'], $f_name, $config_link));
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_link." is described as NOT NULL, but does not have DEFAULT value !");
+ $debugger->appendHTML(sprintf($error_messages['not_null_error2'], $f_name, $config_link));
safeDefine('DBG_RAISE_ON_WARNINGS', 1);
}
-
- if (!$default_missing) {
- if ($f_name == $config['IDField'] && $options['default'] !== 0) {
- $debugger->appendHTML("Config Error: Default value for field IDField $f_name (".var_export($options['default'], true).") in config for prefix ".$config_link." differs from default value from field in database (".var_export($field['Default'], true).") !");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
- else if ($options['default'] != '#NOW#' && $field['Default'] !== (string)$options['default'] && !in_array($options['type'], $float_types)) {
- $debugger->appendHTML("Config Error: Default value for field $f_name (".var_export($options['default'], true).") in config for prefix ".$config_link." differs from default value from field in database (".var_export($field['Default'], true).") !");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
+ }
+
+ if (!$default_missing) {
+ if ($f_name == $config['IDField'] && $options['default'] !== 0) {
+ $debugger->appendHTML(sprintf($error_messages['invalid_default'], 'IDField ', $f_name, var_export($options['default'], true), $config_link, var_export($field['Default'], true)));
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
}
-
- // check that all idfields have default values & are not_null!!!
+ else if ($options['default'] != '#NOW#' && $field['Default'] !== (string)$options['default'] && !in_array($options['type'], $float_types)) {
+ $debugger->appendHTML(sprintf($error_messages['invalid_default'], '', $f_name, var_export($options['default'], true), $config_link, var_export($field['Default'], true)));
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
+ }
}
-
}
}
}