Skip to content

Commit a105985

Browse files
committedJan 2, 2012
Fix SQL errors with SQL Server
This commit addresses 2 occurences of SQL Server error: "Operand type clash: int is incompatible with text" which are triggered when calling the following functions: - config_set() - token_create() - token_update() This is due to the field "Value" in the relevant Mantis table being of type TEXT, while the corresponding value in the array passed in call to db_query_bound() is not a string. Thanks to genius_p for the original patch. Fixes #12081, #12082
1 parent 04bf9d6 commit a105985

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

Diff for: ‎core/config_api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ function config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PR
357357
project_id = " . db_param() . " AND
358358
user_id = " . db_param();
359359
$t_params = Array(
360-
$c_value,
360+
(string)$c_value,
361361
$t_type,
362362
$c_access,
363363
$c_option,
@@ -370,7 +370,7 @@ function config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PR
370370
VALUES
371371
(" . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ',' . db_param() . ' )';
372372
$t_params = Array(
373-
$c_value,
373+
(string)$c_value,
374374
$t_type,
375375
$c_access,
376376
$c_option,

Diff for: ‎core/tokens_api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function token_create( $p_type, $p_value, $p_expiry = TOKEN_EXPIRY, $p_user_id =
210210
$t_query = "INSERT INTO $t_tokens_table
211211
( type, value, timestamp, expiry, owner )
212212
VALUES ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
213-
db_query_bound( $t_query, Array( $c_type, $p_value, $c_timestamp, $c_expiry, $c_user_id ) );
213+
db_query_bound( $t_query, Array( $c_type, (string)$p_value, $c_timestamp, $c_expiry, $c_user_id ) );
214214
return db_insert_id( $t_tokens_table );
215215
}
216216

@@ -231,7 +231,7 @@ function token_update( $p_token_id, $p_value, $p_expiry = TOKEN_EXPIRY ) {
231231
$t_query = "UPDATE $t_tokens_table
232232
SET value=" . db_param() . ", expiry=" . db_param() . "
233233
WHERE id=" . db_param();
234-
db_query_bound( $t_query, Array( $p_value, $c_expiry, $c_token_id ) );
234+
db_query_bound( $t_query, Array( (string)$p_value, $c_expiry, $c_token_id ) );
235235

236236
return true;
237237
}

0 commit comments

Comments
 (0)
Please sign in to comment.