Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 791fbd93d09b
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 32ba11600018
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Oct 4, 2012

  1. Whitespace fixes

    dregad committed Oct 4, 2012
    Copy the full SHA
    6ecddde View commit details
  2. Fix issue in tag api with odbc_mssql driver

    This branch of code was put into place to handle a deficiency in the
    odbc_mssql driver that doesn't allow for bound subqueries. This is not
    needed for the other mssql drivers, yet using db_is_mssql() returns true
    for all mssql drivers so code is indiscriminately executed for other
    drivers.
    
    $t_params[] init was changed because it only needs to be set once. It is
    needed for the query in the mssql condition block for the first query
    only to grab the list of tags that aren't specific to this bug.
    Afterwards in the second query, $t_params needs to be null or it results
    in the database returning an error due to no '?' replacements.
    Therefore, after running the first query, we need to set this to null.
    If the condition fails and the dbtype is not mssql (or 'odbc_mssql')
    then $t_params is already set.
    
    Note: the multiple query setup in the "true" condition is a really bad
    way to do this. I'm not going to mess with it, however, since the tag
    count probably won't get too high in any general scenario.
    
    Fixes #14774
    
    Signed-off-by: Damien Regad <damien.regad@merckgroup.com>
    
    Note, this was simply checked for syntax errors and compliance with
    coding guidelines as I don't have access to an MSSQL setup.
    bstidham authored and dregad committed Oct 4, 2012
    Copy the full SHA
    32ba116 View commit details
Showing with 22 additions and 20 deletions.
  1. +22 −20 core/tag_api.php
42 changes: 22 additions & 20 deletions core/tag_api.php
Original file line number Diff line number Diff line change
@@ -214,30 +214,30 @@ function tag_parse_filters( $p_string ) {

/**
* Returns all available tags
*
*
* @param integer A string to match the beginning of the tag name
* @param integer the number of tags to return
* @param integer the offset of the result
*
*
* @return array Tag rows, sorted by name
*/
function tag_get_all( $p_name_filter, $p_count, $p_offset) {

$t_tag_table = db_get_table( 'mantis_tag_table' );

$t_where = '';
$t_where_params = array();

if ( !is_blank( $p_name_filter ) ) {
$t_where = 'WHERE '.db_helper_like('name');
$t_where_params[] = $p_name_filter.'%';
}

$t_query = "SELECT * FROM $t_tag_table
$t_where ORDER BY name";

$t_result = db_query_bound( $t_query, $t_where_params, $p_count, $p_offset);

return $t_result;
}

@@ -246,23 +246,23 @@ function tag_get_all( $p_name_filter, $p_count, $p_offset) {
* @param integer A string to match the beginning of the tag name
*/
function tag_count ( $p_name_filter ) {

$t_tag_table = db_get_table( 'mantis_tag_table' );

$t_where = '';
$t_where_params = array();

if ( $p_name_filter ) {
$t_where = 'WHERE '.db_helper_like('name');
$t_where_params[] = $p_name_filter.'%';
}

$t_query = "SELECT count(*) FROM $t_tag_table $t_where";

$t_result = db_query_bound( $t_query, $t_where_params );
$t_row = db_fetch_array( $t_result );
return (int)db_result( $t_result );

}

/**
@@ -463,23 +463,26 @@ function tag_get_candidates_for_bug( $p_bug_id ) {
if ( 0 != $p_bug_id ) {
$t_bug_tag_table = db_get_table( 'mantis_bug_tag_table' );

if ( db_is_mssql() ) {
$t_params[] = $p_bug_id;
$t_params[] = $p_bug_id;

if ( config_get_global( 'db_type' ) == 'odbc_mssql' ) {
$query = "SELECT t.id FROM $t_tag_table t
LEFT JOIN $t_bug_tag_table b ON t.id=b.tag_id
WHERE b.bug_id IS NULL OR b.bug_id != " . db_param();
$result = db_query_bound( $query, $t_params );

$t_params = null;

$t_subquery_results = array();

while( $row = db_fetch_array( $result ) ) {
$t_subquery_results[] = (int)$row['id'];
}

if ( count ( $t_subquery_results ) == 0 ) {
return array();
return array();
}

$query = "SELECT id, name, description FROM $t_tag_table WHERE id IN ( " . implode( ', ', $t_subquery_results ) . ')';
} else {
$query = "SELECT id, name, description FROM $t_tag_table WHERE id IN (
@@ -488,7 +491,6 @@ function tag_get_candidates_for_bug( $p_bug_id ) {
WHERE b.bug_id IS NULL OR b.bug_id != " . db_param() .
')';
}
$t_params[] = $p_bug_id;
} else {
$query = 'SELECT id, name, description FROM ' . $t_tag_table;
}