Skip to content

Commit fa332f3

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 385e0c9 commit fa332f3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎core/config_api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ function config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PR
346346
project_id = " . db_param() . " AND
347347
user_id = " . db_param();
348348
$t_params = Array(
349-
$c_value,
349+
(string)$c_value,
350350
$t_type,
351351
$c_access,
352352
$c_option,
@@ -359,7 +359,7 @@ function config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PR
359359
VALUES
360360
(" . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ',' . db_param() . ' )';
361361
$t_params = Array(
362-
$c_value,
362+
(string)$c_value,
363363
$t_type,
364364
$c_access,
365365
$c_option,

‎core/tokens_api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function token_create( $p_type, $p_value, $p_expiry = TOKEN_EXPIRY, $p_user_id =
200200
$t_query = "INSERT INTO $t_tokens_table
201201
( type, value, timestamp, expiry, owner )
202202
VALUES ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
203-
db_query_bound( $t_query, Array( $c_type, $p_value, $c_timestamp, $c_expiry, $c_user_id ) );
203+
db_query_bound( $t_query, Array( $c_type, (string)$p_value, $c_timestamp, $c_expiry, $c_user_id ) );
204204
return db_insert_id( $t_tokens_table );
205205
}
206206

@@ -221,7 +221,7 @@ function token_update( $p_token_id, $p_value, $p_expiry = TOKEN_EXPIRY ) {
221221
$t_query = "UPDATE $t_tokens_table
222222
SET value=" . db_param() . ", expiry=" . db_param() . "
223223
WHERE id=" . db_param();
224-
db_query_bound( $t_query, Array( $p_value, $c_expiry, $c_token_id ) );
224+
db_query_bound( $t_query, Array( (string)$p_value, $c_expiry, $c_token_id ) );
225225

226226
return true;
227227
}

0 commit comments

Comments
 (0)