Fixes to the 'key' column of the 'tupdate_settings' table

This commit is contained in:
Alejandro Gallardo Escobar 2015-06-25 16:16:01 +02:00
parent aea50e915a
commit 4e8c85ec10
8 changed files with 29 additions and 54 deletions

View File

@ -185,13 +185,13 @@ switch ($config["dbtype"]) {
render_info_data ("SELECT value render_info_data ("SELECT value
FROM tupdate_settings FROM tupdate_settings
WHERE key = 'customer_key'", "Update Key"); WHERE \"key\" = 'customer_key'", "Update Key");
render_info_data ("SELECT value render_info_data ("SELECT value
FROM tupdate_settings FROM tupdate_settings
WHERE key = 'updating_code_path'", "Updating code path"); WHERE \"key\" = 'updating_code_path'", "Updating code path");
render_info_data ("SELECT value render_info_data ("SELECT value
FROM tupdate_settings FROM tupdate_settings
WHERE key = 'current_update'", "Current Update #"); WHERE \"key\" = 'current_update'", "Current Update #");
break; break;
} }

View File

@ -33,7 +33,7 @@ switch ($config['dbtype']) {
$type_escaped = "type"; $type_escaped = "type";
break; break;
case "oracle": case "oracle":
$type_escaped = db_encapsule_fields_with_same_name_to_instructions( $type_escaped = db_escape_key_identifier(
"type"); "type");
break; break;
} }

View File

@ -1075,7 +1075,7 @@ switch ($action) {
case "oracle": case "oracle":
if (isset($values['type'])) { if (isset($values['type'])) {
$values[ $values[
db_encapsule_fields_with_same_name_to_instructions( db_escape_key_identifier(
"type")] = $values['type']; "type")] = $values['type'];
unset($values['type']); unset($values['type']);
} }
@ -1333,7 +1333,7 @@ switch ($action) {
case "oracle": case "oracle":
if (isset($values['type'])) { if (isset($values['type'])) {
$values[ $values[
db_encapsule_fields_with_same_name_to_instructions( db_escape_key_identifier(
"type")] = $values['type']; "type")] = $values['type'];
unset($values['type']); unset($values['type']);
} }

View File

@ -28,8 +28,10 @@ ui_print_page_header (__('License management'), "images/extensions.png", false,
if ($update_settings) { if ($update_settings) {
foreach ($_POST['keys'] as $key => $value) { foreach ($_POST['keys'] as $key => $value) {
db_process_sql_update('tupdate_settings', db_process_sql_update(
array('value' => $value), array('key' => $key)); 'tupdate_settings',
array('value' => $value),
array(db_escape_key_identifier('key') => $key));
} }
ui_print_success_message(__('License updated')); ui_print_success_message(__('License updated'));

View File

@ -167,7 +167,7 @@ function config_update_config () {
$license_info_key = get_parameter('license_info_key', ''); $license_info_key = get_parameter('license_info_key', '');
if (!empty($license_info_key)) { if (!empty($license_info_key)) {
$values = array("value" => $license_info_key); $values = array("value" => $license_info_key);
$where = array("key" => 'customer_key'); $where = array(db_escape_key_identifier('key') => 'customer_key');
$update_manage_settings_result = db_process_sql_update('tupdate_settings', $values, $where); $update_manage_settings_result = db_process_sql_update('tupdate_settings', $values, $where);
if ($update_manage_settings_result === false) if ($update_manage_settings_result === false)
$error_update[] = __('License information'); $error_update[] = __('License information');

View File

@ -125,6 +125,11 @@ function db_encapsule_fields_with_same_name_to_instructions($field) {
} }
} }
// Alias for 'db_encapsule_fields_with_same_name_to_instructions'
function db_escape_key_identifier($field) {
return db_encapsule_fields_with_same_name_to_instructions($field);
}
/** /**
* Adds an audit log entry (new function in 3.0) * Adds an audit log entry (new function in 3.0)
* *

View File

@ -24,31 +24,14 @@ function update_manager_get_config_values() {
global $build_version; global $build_version;
global $pandora_version; global $pandora_version;
switch ($config["dbtype"]) { $license = db_get_value(
case "postgresql": 'value',
case "mysql": 'tupdate_settings',
$license = db_get_value( db_escape_key_identifier('key'),
db_encapsule_fields_with_same_name_to_instructions('value'), 'customer_key');
'tupdate_settings',
db_encapsule_fields_with_same_name_to_instructions('key'),
'customer_key');
break;
case 'oracle':
$license = db_get_value(
'value',
'tupdate_settings',
'key',
'customer_key');
break;
}
$limit_count = db_get_value_sql("SELECT count(*) FROM tagente"); $limit_count = db_get_value_sql("SELECT count(*) FROM tagente");
return array( return array(
'license' => $license, 'license' => $license,
'current_update' => update_manager_get_current_package(), 'current_update' => update_manager_get_current_package(),
@ -497,8 +480,8 @@ function update_manager_set_current_package($current_package) {
$token = 'current_package'; $token = 'current_package';
} }
$col_value = db_encapsule_fields_with_same_name_to_instructions('value'); $col_value = 'value';
$col_key = db_encapsule_fields_with_same_name_to_instructions('key'); $col_key = db_escape_key_identifier('key');
$value = db_get_value($col_value, $value = db_get_value($col_value,
'tupdate_settings', $col_key, $token); 'tupdate_settings', $col_key, $token);
@ -523,26 +506,11 @@ function update_manager_get_current_package() {
else { else {
$token = 'current_package'; $token = 'current_package';
} }
$current_update = db_get_value(
switch ($config["dbtype"]) { 'value',
case "postgresql": 'tupdate_settings',
case "mysql": db_escape_key_identifier('key'),
$current_update = db_get_value( $token);
db_encapsule_fields_with_same_name_to_instructions('value'),
'tupdate_settings',
db_encapsule_fields_with_same_name_to_instructions('key'),
$token);
break;
case "oracle":
$current_update = db_get_value(
'value',
'tupdate_settings',
'key',
$token);
break;
}
if ($current_update === false) { if ($current_update === false) {
$current_update = 0; $current_update = 0;

View File

@ -1956,7 +1956,7 @@ CREATE OR REPLACE TRIGGER tcategory_inc BEFORE INSERT ON tcategory REFERENCING N
-- Table `tupdate_settings` -- Table `tupdate_settings`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
CREATE TABLE tupdate_settings ( CREATE TABLE tupdate_settings (
key VARCHAR2(255) DEFAULT '' PRIMARY KEY, "key" VARCHAR2(255) DEFAULT '' PRIMARY KEY,
value VARCHAR2(255) DEFAULT '' value VARCHAR2(255) DEFAULT ''
); );