Skip to content

Commit

Permalink
Fix SQL errors with SQL Server
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dregad committed Jan 2, 2012
1 parent 04bf9d6 commit a105985
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/config_api.php
Expand Up @@ -357,7 +357,7 @@ function config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PR
project_id = " . db_param() . " AND
user_id = " . db_param();
$t_params = Array(
$c_value,
(string)$c_value,
$t_type,
$c_access,
$c_option,
Expand All @@ -370,7 +370,7 @@ function config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PR
VALUES
(" . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ',' . db_param() . ' )';
$t_params = Array(
$c_value,
(string)$c_value,
$t_type,
$c_access,
$c_option,
Expand Down
4 changes: 2 additions & 2 deletions core/tokens_api.php
Expand Up @@ -210,7 +210,7 @@ function token_create( $p_type, $p_value, $p_expiry = TOKEN_EXPIRY, $p_user_id =
$t_query = "INSERT INTO $t_tokens_table
( type, value, timestamp, expiry, owner )
VALUES ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
db_query_bound( $t_query, Array( $c_type, $p_value, $c_timestamp, $c_expiry, $c_user_id ) );
db_query_bound( $t_query, Array( $c_type, (string)$p_value, $c_timestamp, $c_expiry, $c_user_id ) );
return db_insert_id( $t_tokens_table );
}

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

return true;
}
Expand Down

0 comments on commit a105985

Please sign in to comment.