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: 3854c4d1f1ca
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fbb5e95e2b8c
Choose a head ref
  • 3 commits
  • 7 files changed
  • 1 contributor

Commits on Apr 6, 2013

  1. reformatting

    mantis committed Apr 6, 2013
    Copy the full SHA
    86448ed View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    vcunat Vladimír Čunát
    Copy the full SHA
    48d7b23 View commit details
  3. Port of 7beac56 [dregad]:

    MantisGraph: incorrect issues count in graph by severity
    When $g_bug_closed_status_threshold is not the "final" entry in
    status_enum_string list, function enum_bug_group() in graph_api.php
    computed the number of closed issues incorrectly due to use of '='
    operator instead of '>=' in the query's where clause.
    
    Also corrects some trailing whitespace.
    
    Fixes #14356
    mantis committed Apr 6, 2013
    Copy the full SHA
    fbb5e95 View commit details
Showing with 24 additions and 60 deletions.
  1. +3 −2 core/bug_api.php
  2. +4 −10 core/category_api.php
  3. +1 −7 core/email_queue_api.php
  4. +5 −11 core/profile_api.php
  5. +6 −15 core/project_api.php
  6. +4 −14 core/project_hierarchy_api.php
  7. +1 −1 plugins/MantisGraph/core/graph_api.php
5 changes: 3 additions & 2 deletions core/bug_api.php
Original file line number Diff line number Diff line change
@@ -455,8 +455,9 @@ function bug_move( $p_bug_id, $p_target_project_id ) {
if ( $t_category_project_id != ALL_PROJECTS ) {
// Map by name
$t_category_name = category_get_field( $t_category_id, 'name' );
$t_target_project_category_id = category_get_id_by_name( $t_category_name, $p_target_project_id, /* triggerErrors */ false );
if ( $t_target_project_category_id === false ) {
try {
$t_target_project_category_id = category_get_id_by_name( $t_category_name, $p_target_project_id );
} catch ( MantisBT\Exception\Project\Category\CategoryNotFound $e ) {
// Use default category after moves, since there is no match by name.
$t_target_project_category_id = config_get( 'default_category_for_moves' );
}
14 changes: 4 additions & 10 deletions core/category_api.php
Original file line number Diff line number Diff line change
@@ -527,26 +527,20 @@ function category_get_name( $p_category_id ) {
* category with that name.
* @param string $p_category_name category name
* @param int $p_project_id project id
* @param bool $p_trigger_errors trigger error on failure
* @return bool
* @access public
* @throws MantisBT\Exception\Project\Category\CategoryNotFound
*/
function category_get_id_by_name( $p_category_name, $p_project_id, $p_trigger_errors = true ) {
function category_get_id_by_name( $p_category_name, $p_project_id ) {
$t_project_name = project_get_name( $p_project_id );

$t_query = 'SELECT id FROM {category} WHERE name=%s AND project_id=%d';
$t_result = db_query( $t_query, array( $p_category_name, (int) $p_project_id ) );
$t_id = db_result( $t_result );
if( $t_id ) {
if( $p_trigger_errors ) {
throw new MantisBT\Exception\Project\Category\CategoryNotFound( $p_category_name, $t_project_name );
} else {
return false;
}
if( $t_id > 0 ) {
return $t_id;
}

return $t_id;
throw new MantisBT\Exception\Project\Category\CategoryNotFound( $p_category_name, $t_project_name );
}

/**
8 changes: 1 addition & 7 deletions core/email_queue_api.php
Original file line number Diff line number Diff line change
@@ -113,13 +113,7 @@ function email_queue_add( $p_email_data ) {
$c_body = $t_email_data->body;
$c_metadata = serialize( $t_email_data->metadata );

$t_query = "INSERT INTO {email}
( email,
subject,
body,
submitted,
metadata)
VALUES ( %s, %s, %s, %d, %s )";
$t_query = "INSERT INTO {email} ( email, subject, body, submitted, metadata) VALUES ( %s, %s, %s, %d, %s )";
db_query( $t_query, array( $c_email, $c_subject, $c_body, db_now(), $c_metadata ) );

return db_insert_id( '{email}', 'email_id' );
16 changes: 5 additions & 11 deletions core/profile_api.php
Original file line number Diff line number Diff line change
@@ -72,10 +72,8 @@ function profile_create( $p_user_id, $p_platform, $p_os, $p_os_build, $p_descrip
}

# Add profile
$query = "INSERT INTO {user_profile}
( user_id, platform, os, os_build, description )
VALUES
( %d, %s, %s, %s, %s )";
$query = "INSERT INTO {user_profile} ( user_id, platform, os, os_build, description )
VALUES ( %d, %s, %s, %s, %s )";
db_query( $query, array( $p_user_id, $p_platform, $p_os, $p_os_build, $p_description ) );

return db_insert_id( '{user_profile}' );
@@ -144,8 +142,7 @@ function profile_update( $p_user_id, $p_profile_id, $p_platform, $p_os, $p_os_bu
}

# Add item
$query = "UPDATE {user_profile}
SET platform=%s, os=%s, os_build=%s, description=%s
$query = "UPDATE {user_profile} SET platform=%s, os=%s, os_build=%s, description=%s
WHERE id=%d AND user_id=%d";
$result = db_query( $query, array( $p_platform, $p_os, $p_os_build, $p_description, $p_profile_id, $p_user_id ) );
}
@@ -234,9 +231,7 @@ function profile_get_field_all_for_user( $p_field, $p_user_id = null ) {
throw new MantisBT\Exception\UnknownException();
}

$t_query = "SELECT DISTINCT $c_field FROM {user_profile}
WHERE ( user_id=%d ) OR ( user_id = 0 )
ORDER BY $c_field";
$t_query = "SELECT DISTINCT $c_field FROM {user_profile} WHERE ( user_id=%d ) OR ( user_id = 0 ) ORDER BY $c_field";
$t_result = db_query( $t_query, array( $c_user_id ) );

$t_rows = array();
@@ -259,8 +254,7 @@ function profile_get_all_for_project( $p_project_id ) {
# using up.* causes an SQL error on MS SQL since up.description is of type text
$t_query = "SELECT DISTINCT(up.id), up.user_id, up.platform, up.os, up.os_build
FROM {user_profile} up, {bug} b
WHERE $t_project_where
AND up.id = b.profile_id
WHERE $t_project_where AND up.id = b.profile_id
ORDER BY up.platform, up.os, up.os_build";
$t_result = db_query( $t_query );

21 changes: 6 additions & 15 deletions core/project_api.php
Original file line number Diff line number Diff line change
@@ -281,10 +281,8 @@ function project_create( $p_name, $p_description, $p_status, $p_view_state = VS_
file_ensure_valid_upload_path( $p_file_path );
}

$t_query = "INSERT INTO {project}
( name, status, enabled, view_state, file_path, description, inherit_global )
VALUES
( %s, %d, %d, %d, %s, %s, %d)";
$t_query = "INSERT INTO {project} ( name, status, enabled, view_state, file_path, description, inherit_global )
VALUES ( %s, %d, %d, %d, %s, %s, %d)";

db_query( $t_query, array( $p_name, (int) $p_status, $p_enabled, (int) $p_view_state, $p_file_path, $p_description, $p_inherit_global ) );

@@ -379,10 +377,8 @@ function project_update( $p_project_id, $p_name, $p_description, $p_status, $p_v
file_ensure_valid_upload_path( $p_file_path );
}

$t_query = "UPDATE {project}
SET name=%s, status=%d, enabled=%d, view_state=%d,
file_path=%s, description=%s, inherit_global=%d
WHERE id=%d";
$t_query = "UPDATE {project} SET name=%s, status=%d, enabled=%d, view_state=%d, file_path=%s, description=%s, inherit_global=%d
WHERE id=%d";
db_query( $t_query, array( $p_name, (int) $p_status, $p_enabled, (int) $p_view_state, $p_file_path, $p_description, $p_inherit_global, $p_project_id ) );

project_clear_cache( $p_project_id );
@@ -596,9 +592,7 @@ function project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_leve
}

if( $p_include_global_users ) {
$t_query = "SELECT id, username, realname, access_level
FROM {user} WHERE enabled = %d
AND access_level $t_global_access_clause";
$t_query = "SELECT id, username, realname, access_level FROM {user} WHERE enabled = %d AND access_level $t_global_access_clause";

$t_result = db_query( $t_query, array( $t_on ) );
while( $t_row = db_fetch_array( $t_result ) ) {
@@ -650,10 +644,7 @@ function project_add_user( $p_project_id, $p_user_id, $p_access_level ) {
$c_access_level = (int)( user_get_access_level( $p_user_id ) );
}

$t_query = "INSERT INTO {project_user_list}
( project_id, user_id, access_level )
VALUES
( %d, %d, %d)";
$t_query = "INSERT INTO {project_user_list} ( project_id, user_id, access_level ) VALUES ( %d, %d, %d)";

db_query( $t_query, array( $p_project_id, $p_user_id, $p_access_level ) );

18 changes: 4 additions & 14 deletions core/project_hierarchy_api.php
Original file line number Diff line number Diff line change
@@ -48,11 +48,7 @@ function project_hierarchy_add( $p_child_id, $p_parent_id, $p_inherit_parent = t
throw new MantisBT\Exception\Project\RecursiveHierarchyNotAllowed();
}

$t_query = "INSERT INTO {project_hierarchy}
( child_id, parent_id, inherit_parent )
VALUES
( %d, %d, %d )";

$t_query = "INSERT INTO {project_hierarchy} ( child_id, parent_id, inherit_parent ) VALUES ( %d, %d, %d )";
db_query( $t_query, array( $p_child_id, $p_parent_id, $p_inherit_parent ) );
}

@@ -76,7 +72,6 @@ function project_hierarchy_update( $p_child_id, $p_parent_id, $p_inherit_parent
*/
function project_hierarchy_remove( $p_child_id, $p_parent_id ) {
$t_query = "DELETE FROM {project_hierarchy} WHERE child_id = %d AND parent_id = %d";

db_query( $t_query, array( $p_child_id, $p_parent_id ) );
}

@@ -87,7 +82,6 @@ function project_hierarchy_remove( $p_child_id, $p_parent_id ) {
*/
function project_hierarchy_remove_all( $p_project_id ) {
$query = "DELETE FROM {project_hierarchy} WHERE child_id = %d OR parent_id = %d";

db_query( $query, array( $p_project_id, $p_project_id ) );
}

@@ -138,7 +132,6 @@ function project_hierarchy_cache( $p_show_disabled = false ) {
$g_cache_project_inheritance = array();

while ( $row = db_fetch_array( $result ) ) {

if( null === $row['parent_id'] ) {
$row['parent_id'] = ALL_PROJECTS;
}
@@ -158,6 +151,7 @@ function project_hierarchy_cache( $p_show_disabled = false ) {
if( $row['inherit_global'] && !isset( $g_cache_project_inheritance[(int)$row['id']][ALL_PROJECTS] ) ) {
$g_cache_project_inheritance[(int)$row['id']][] = ALL_PROJECTS;
}

if( $row['inherit_parent'] && !isset( $g_cache_project_inheritance[(int)$row['id']][(int)$row['parent_id']] ) ) {
$g_cache_project_inheritance[(int)$row['id']][] = (int) $row['parent_id'];
}
@@ -191,12 +185,8 @@ function project_hierarchy_inheritance( $p_project_id, $p_show_disabled = false

project_hierarchy_cache( $p_show_disabled );

$t_project_ids = array(
(int) $p_project_id,
);
$t_lookup_ids = array(
(int) $p_project_id,
);
$t_project_ids = array( (int) $p_project_id, );
$t_lookup_ids = array( (int) $p_project_id, );

while( count( $t_lookup_ids ) > 0 ) {
$t_project_id = array_shift( $t_lookup_ids );
2 changes: 1 addition & 1 deletion plugins/MantisGraph/core/graph_api.php
Original file line number Diff line number Diff line change
@@ -677,7 +677,7 @@ function enum_bug_group( $p_enum_string, $p_enum ) {

# Calculates the number of bugs closed and puts the results in a table
$query = "SELECT COUNT(*) FROM {bug}
WHERE $p_enum=%d AND status=%d $specific_where";
WHERE $p_enum=%d AND status>=%d $specific_where";
$result2 = db_query( $query, array( $t_value, $t_clo_val ) );
$t_metrics['closed'][$t_label] = db_result( $result2 );