Skip to content

Commit

Permalink
Shorten db_query_bound to db_query
Browse files Browse the repository at this point in the history
We add a function "alias" for db_query_bound so that
existing code will continue to work.

We rename db_query_bound to db_query within mantis core.

Long term, this allows us to shorten db_query_bound() to a more sensible
db_query() call and to remove the function in 2.0 as it gives plugin
authors time to update their code and support both 1.3 and 2.0
  • Loading branch information
mantis committed Sep 5, 2014
1 parent f960f93 commit b7e258c
Show file tree
Hide file tree
Showing 63 changed files with 433 additions and 425 deletions.
4 changes: 2 additions & 2 deletions account_sponsor_page.php
Expand Up @@ -120,7 +120,7 @@
AND ' . $t_project_clause . '
ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC';

$t_result = db_query_bound( $t_query, $t_show_all ? array( $t_user ) : array( $t_user , $t_resolved ) );
$t_result = db_query( $t_query, $t_show_all ? array( $t_user ) : array( $t_user , $t_resolved ) );

$t_sponsors = array();
while( $t_row = db_fetch_array( $t_result ) ) {
Expand Down Expand Up @@ -235,7 +235,7 @@
AND ' . $t_project_clause . '
ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC';

$t_result = db_query_bound( $t_query, $t_show_all ? array( $t_user ) : array( $t_user , $t_resolved ) );
$t_result = db_query( $t_query, $t_show_all ? array( $t_user ) : array( $t_user , $t_resolved ) );

$t_sponsors = array();
while( $t_row = db_fetch_array( $t_result ) ) {
Expand Down
8 changes: 4 additions & 4 deletions adm_config_report.php
Expand Up @@ -214,7 +214,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {

# Get users in db having specific configs
$t_query = 'SELECT DISTINCT user_id FROM {config} WHERE user_id <> ' . db_param() ;
$t_result = db_query_bound( $t_query, array( ALL_USERS ) );
$t_result = db_query( $t_query, array( ALL_USERS ) );
if( $t_filter_user_value != META_FILTER_NONE && $t_filter_user_value != ALL_USERS ) {
# Make sure the filter value exists in the list
$t_users_list[$t_filter_user_value] = user_get_name( $t_filter_user_value );
Expand All @@ -239,7 +239,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {
JOIN {project} pt ON pt.id = ct.project_id
WHERE project_id!=0
ORDER BY project_name';
$t_result = db_query_bound( $t_query );
$t_result = db_query( $t_query );
$t_projects_list[META_FILTER_NONE] = '[' . lang_get( 'any' ) . ']';
$t_projects_list[ALL_PROJECTS] = lang_get( 'all_projects' );
while( $t_row = db_fetch_array( $t_result ) ) {
Expand All @@ -249,7 +249,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {

# Get config list used in db
$t_query = 'SELECT DISTINCT config_id FROM {config} ORDER BY config_id';
$t_result = db_query_bound( $t_query );
$t_result = db_query( $t_query );
$t_configs_list[META_FILTER_NONE] = '[' . lang_get( 'any' ) . ']';
if( $t_filter_config_value != META_FILTER_NONE ) {
# Make sure the filter value exists in the list
Expand Down Expand Up @@ -281,7 +281,7 @@ function print_option_list_from_array( array $p_array, $p_filter_value ) {

$t_query = 'SELECT config_id, user_id, project_id, type, value, access_reqd
FROM {config} ' . $t_where . ' ORDER BY user_id, project_id, config_id ';
$t_result = db_query_bound( $t_query, $t_param );
$t_result = db_query( $t_query, $t_param );
?>

<!-- FILTER FORM -->
Expand Down
4 changes: 2 additions & 2 deletions admin/check/check_database_inc.php
Expand Up @@ -376,7 +376,7 @@
break;
}

$t_result = db_query_bound( 'SHOW TABLE STATUS' );
$t_result = db_query( 'SHOW TABLE STATUS' );
while( $t_row = db_fetch_array( $t_result ) ) {
if( $t_row[$t_field_comment] !== 'VIEW' &&
preg_match( '/^' . $t_table_prefix_regex_safe . '.+?' . $t_table_suffix_regex_safe . '$/', $t_row[$t_field_name] )
Expand All @@ -392,7 +392,7 @@

foreach( db_get_table_list() as $t_table ) {
if( preg_match( '/^' . $t_table_prefix_regex_safe . '.+?' . $t_table_suffix_regex_safe . '$/', $t_table ) ) {
$t_result = db_query_bound( 'SHOW FULL FIELDS FROM ' . $t_table );
$t_result = db_query( 'SHOW FULL FIELDS FROM ' . $t_table );
while( $t_row = db_fetch_array( $t_result ) ) {
if( $t_row[$t_field_collation] === null ) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion admin/db_stats.php
Expand Up @@ -52,7 +52,7 @@ function print_info_row( $p_description, $p_value ) {
function helper_table_row_count( $p_table ) {
$t_table = $p_table;
$t_query = 'SELECT COUNT(*) FROM ' . $t_table;
$t_result = db_query_bound( $t_query );
$t_result = db_query( $t_query );
$t_count = db_result( $t_result );

return $t_count;
Expand Down
10 changes: 5 additions & 5 deletions admin/move_attachments.php
Expand Up @@ -65,7 +65,7 @@ function move_attachments_to_db( $p_type, $p_projects ) {
# Process projects list
foreach( $p_projects as $t_project ) {
# Retrieve attachments for the project
$t_result = db_query_bound( $t_query, array( $t_project ) );
$t_result = db_query( $t_query, array( $t_project ) );

# Project upload path
$t_upload_path = project_get_field( $t_project, 'file_path' );
Expand Down Expand Up @@ -99,13 +99,13 @@ function move_attachments_to_db( $p_type, $p_projects ) {
if( db_is_oracle() ) {
db_update_blob( $t_file_table, 'content', $c_content, "id=" . (int)$t_row['id'] );
$t_query = "UPDATE $t_file_table SET folder='' WHERE id = " . db_param();
$t_result2 = db_query_bound( $t_query, array( (int)$t_row['id'] ) );
$t_result2 = db_query( $t_query, array( (int)$t_row['id'] ) );
} else {
$t_update_query = "UPDATE $t_file_table
SET folder = " . db_param() . ",
content = " . db_param() . "
WHERE id = " . db_param();
$t_result2 = db_query_bound( $t_update_query,
$t_result2 = db_query( $t_update_query,
array( '', $c_content, (int)$t_row['id'] )
);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ function move_attachments_to_disk( $p_type, array $p_projects ) {
# Process projects list
foreach( $p_projects as $t_project ) {
# Retrieve attachments for the project
$t_result = db_query_bound( $t_query, array( $t_project ) );
$t_result = db_query( $t_query, array( $t_project ) );

# Project upload path
$t_upload_path = project_get_upload_path( $t_project );
Expand Down Expand Up @@ -215,7 +215,7 @@ function move_attachments_to_disk( $p_type, array $p_projects ) {
WHERE id = ' . db_param();
break;
}
$t_update_result = db_query_bound(
$t_update_result = db_query(
$t_update_query,
array( $t_upload_path, $t_row['id'] )
);
Expand Down
2 changes: 1 addition & 1 deletion admin/move_attachments_page.php
Expand Up @@ -63,7 +63,7 @@ function get_attachment_stats( $p_file_type, $p_in_db ) {
ORDER BY p.name";
break;
}
$t_result = db_query_bound( $t_query );
$t_result = db_query( $t_query );
$t_stats = array();

while( $t_row = db_fetch_array( $t_result ) ) {
Expand Down
2 changes: 1 addition & 1 deletion api/soap/mc_api.php
Expand Up @@ -516,7 +516,7 @@ function mci_filter_db_get_available_queries( $p_project_id = null, $p_user_id =
AND (is_public = ' . db_param() . '
OR user_id = ' . db_param() . ')
ORDER BY is_public DESC, name ASC';
$t_result = db_query_bound( $t_query, array( $t_project_id, db_prepare_bool( true ), $t_user_id ) );
$t_result = db_query( $t_query, array( $t_project_id, db_prepare_bool( true ), $t_user_id ) );
$t_query_count = db_num_rows( $t_result );

for( $i = 0;$i < $t_query_count;$i++ ) {
Expand Down
6 changes: 3 additions & 3 deletions api/soap/mc_file_api.php
Expand Up @@ -147,7 +147,7 @@ function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_ti
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ' )';
db_query_bound( $t_query, array(
db_query( $t_query, array(
$t_id, $p_title, $p_desc,
$t_unique_name, $p_name, $t_file_path,
$t_file_size, $p_file_type, db_now(),
Expand All @@ -161,7 +161,7 @@ function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_ti
db_update_blob( $t_file_table, 'content', $c_content, "diskfile='$t_unique_name'" );
} else {
$t_query = "UPDATE $t_file_table SET content=" . db_param() . " WHERE id = " . db_param();
db_query_bound( $t_query, array( $c_content, $t_attachment_id ) );
db_query( $t_query, array( $c_content, $t_attachment_id ) );
}

if( 'bug' == $p_table ) {
Expand Down Expand Up @@ -198,7 +198,7 @@ function mci_file_get( $p_file_id, $p_type, $p_user_id ) {
return SoapObjectsFactory::newSoapFault( 'Server', 'Invalid file type '. $p_type . ' .' );
}

$t_result = db_query_bound( $t_query, array( $p_file_id ) );
$t_result = db_query( $t_query, array( $p_file_id ) );

if( $t_result->EOF ) {
return SoapObjectsFactory::newSoapFault( 'Client', 'Unable to find an attachment with type ' . $p_type. ' and id ' . $p_file_id . ' .' );
Expand Down
2 changes: 1 addition & 1 deletion api/soap/mc_issue_api.php
Expand Up @@ -565,7 +565,7 @@ function mc_issue_get_id_from_summary( $p_username, $p_password, $p_summary ) {

$t_query = 'SELECT id FROM {bug} WHERE summary = ' . db_param();

$t_result = db_query_bound( $t_query, array( $p_summary ), 1 );
$t_result = db_query( $t_query, array( $p_summary ), 1 );

if( db_num_rows( $t_result ) == 0 ) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion api/soap/mc_project_api.php
Expand Up @@ -734,7 +734,7 @@ function mc_project_get_attachments( $p_username, $p_password, $p_project_id ) {
( ut.access_level = ' . db_param() . ' ) )
ORDER BY pt.name ASC, pft.title ASC';

$t_result = db_query_bound( $t_query, array( $t_user_id, $t_user_id, $t_pub, $t_user_id, $t_admin ) );
$t_result = db_query( $t_query, array( $t_user_id, $t_user_id, $t_pub, $t_user_id, $t_admin ) );
$t_num_files = db_num_rows( $t_result );

$t_attachments = array();
Expand Down
2 changes: 1 addition & 1 deletion changelog_page.php
Expand Up @@ -225,7 +225,7 @@ function print_project_header_changelog ( $p_project_name ) {
$t_issue_parents = array();
$t_issue_handlers = array();

$t_result = db_query_bound( $t_query, array( $t_project_id, $t_version ) );
$t_result = db_query( $t_query, array( $t_project_id, $t_version ) );

while( $t_row = db_fetch_array( $t_result ) ) {
# hide private bugs if user doesn't have access to view them.
Expand Down
4 changes: 2 additions & 2 deletions core/access_api.php
Expand Up @@ -119,7 +119,7 @@ function access_cache_matrix_project( $p_project_id ) {

if( !in_array( (int)$p_project_id, $g_cache_access_matrix_project_ids ) ) {
$t_query = 'SELECT user_id, access_level FROM {project_user_list} WHERE project_id=' . db_param();
$t_result = db_query_bound( $t_query, array( (int)$p_project_id ) );
$t_result = db_query( $t_query, array( (int)$p_project_id ) );
while( $t_row = db_fetch_array( $t_result ) ) {
$g_cache_access_matrix[(int)$t_row['user_id']][(int)$p_project_id] = (int)$t_row['access_level'];
}
Expand Down Expand Up @@ -149,7 +149,7 @@ function access_cache_matrix_user( $p_user_id ) {

if( !in_array( (int)$p_user_id, $g_cache_access_matrix_user_ids ) ) {
$t_query = 'SELECT project_id, access_level FROM {project_user_list} WHERE user_id=' . db_param();
$t_result = db_query_bound( $t_query, array( (int)$p_user_id ) );
$t_result = db_query( $t_query, array( (int)$p_user_id ) );

# make sure we always have an array to return
$g_cache_access_matrix[(int)$p_user_id] = array();
Expand Down
8 changes: 4 additions & 4 deletions core/authentication_api.php
Expand Up @@ -586,7 +586,7 @@ function auth_generate_unique_cookie_string() {
*/
function auth_is_cookie_string_unique( $p_cookie_string ) {
$t_query = 'SELECT COUNT(*) FROM {user} WHERE cookie_string=' . db_param();
$t_result = db_query_bound( $t_query, array( $p_cookie_string ) );
$t_result = db_query( $t_query, array( $p_cookie_string ) );

$t_count = db_result( $t_result );

Expand Down Expand Up @@ -631,7 +631,7 @@ function auth_get_current_user_cookie( $p_login_anonymous = true ) {

# get anonymous information if database is available
$t_query = 'SELECT id, cookie_string FROM {user} WHERE username = ' . db_param();
$t_result = db_query_bound( $t_query, array( config_get( 'anonymous_account' ) ) );
$t_result = db_query( $t_query, array( config_get( 'anonymous_account' ) ) );

if( $t_row = db_fetch_array( $t_result ) ) {
$t_cookie = $t_row['cookie_string'];
Expand Down Expand Up @@ -792,7 +792,7 @@ function auth_is_cookie_valid( $p_cookie_string ) {

# look up cookie in the database to see if it is valid
$t_query = 'SELECT * FROM {user} WHERE cookie_string=' . db_param();
$t_result = db_query_bound( $t_query, array( $p_cookie_string ) );
$t_result = db_query( $t_query, array( $p_cookie_string ) );

# return true if a matching cookie was found
if( 1 == db_num_rows( $t_result ) ) {
Expand Down Expand Up @@ -825,7 +825,7 @@ function auth_get_current_user_id() {

# @todo error with an error saying they aren't logged in? Or redirect to the login page maybe?
$t_query = 'SELECT id FROM {user} WHERE cookie_string=' . db_param();
$t_result = db_query_bound( $t_query, array( $t_cookie_string ) );
$t_result = db_query( $t_query, array( $t_cookie_string ) );

$t_user_id = (int)db_result( $t_result );

Expand Down

0 comments on commit b7e258c

Please sign in to comment.