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
FROM tupdate_settings
WHERE key = 'customer_key'", "Update Key");
WHERE \"key\" = 'customer_key'", "Update Key");
render_info_data ("SELECT value
FROM tupdate_settings
WHERE key = 'updating_code_path'", "Updating code path");
WHERE \"key\" = 'updating_code_path'", "Updating code path");
render_info_data ("SELECT value
FROM tupdate_settings
WHERE key = 'current_update'", "Current Update #");
WHERE \"key\" = 'current_update'", "Current Update #");
break;
}

View File

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

View File

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

View File

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

View File

@ -167,7 +167,7 @@ function config_update_config () {
$license_info_key = get_parameter('license_info_key', '');
if (!empty($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);
if ($update_manage_settings_result === false)
$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)
*

View File

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

View File

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