From 11cc5daf25b4e778452c99f9440b679028c856bb Mon Sep 17 00:00:00 2001 From: Peter Bruin Date: Tue, 25 Jun 2013 09:58:31 +0800 Subject: [PATCH 1/2] (issue #10873) Fixes missing version on roadmap Bugs with a target version that is inherited from a parent project are not shown on the roadmap. This fixes this and leaves the caching feature intact. --- core/version_api.php | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/core/version_api.php b/core/version_api.php index 2aaf287307..16ac9709bf 100644 --- a/core/version_api.php +++ b/core/version_api.php @@ -402,17 +402,47 @@ function version_cache_array_rows( $p_project_id_array ) { */ function version_get_all_rows( $p_project_id, $p_released = null, $p_obsolete = false, $p_inherit = null ) { global $g_cache_versions, $g_cache_versions_project; + + if ( $p_inherit === null ) { + $t_inherit = ( ON == config_get( 'subprojects_inherit_versions' ) ); + } else { + $t_inherit = $p_inherit; + } + + if( $t_inherit ) { + $t_project_ids = project_hierarchy_inheritance( $p_project_id ); + } else { + $t_project_ids [] = $p_project_id; + } - if( isset( $g_cache_versions_project[ (int)$p_project_id ] ) ) { - if( !empty( $g_cache_versions_project[ (int)$p_project_id ]) ) { - foreach( $g_cache_versions_project[ (int)$p_project_id ] as $t_id ) { - $t_versions[] = version_cache_row( $t_id ); + $t_is_cached = true; + foreach ($t_project_ids as $t_project_id ) { + if( !isset( $g_cache_versions_project[ (int)$t_project_id ] ) ) { + $t_is_cached = false; + } + } + if( $t_is_cached ) { + $t_versions = array(); + foreach ($t_project_ids as $t_project_id ) { + if( !empty( $g_cache_versions_project[ (int)$t_project_id ]) ) { + foreach( $g_cache_versions_project[ (int)$t_project_id ] as $t_id ) { + $t_versions[] = version_cache_row( $t_id ); + } } - return $t_versions; - } else { - return array(); } + return $t_versions; } + +# if( isset( $g_cache_versions_project[ (int)$p_project_id ] ) ) { +# if( !empty( $g_cache_versions_project[ (int)$p_project_id ]) ) { +# foreach( $g_cache_versions_project[ (int)$p_project_id ] as $t_id ) { +# $t_versions[] = version_cache_row( $t_id ); +# } +# return $t_versions; +# } else { +# return array(); +# } +# } $c_project_id = db_prepare_int( $p_project_id ); $t_project_version_table = db_get_table( 'mantis_project_version_table' ); From 747481a3b5343b8bb0c6b66c1ca5b48ddf309453 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sun, 29 Sep 2013 23:33:27 +0200 Subject: [PATCH 2/2] Whitespace, remove commented code and unnecessary cast --- core/version_api.php | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/core/version_api.php b/core/version_api.php index 16ac9709bf..61c5badb4c 100644 --- a/core/version_api.php +++ b/core/version_api.php @@ -402,13 +402,13 @@ function version_cache_array_rows( $p_project_id_array ) { */ function version_get_all_rows( $p_project_id, $p_released = null, $p_obsolete = false, $p_inherit = null ) { global $g_cache_versions, $g_cache_versions_project; - + if ( $p_inherit === null ) { $t_inherit = ( ON == config_get( 'subprojects_inherit_versions' ) ); } else { $t_inherit = $p_inherit; } - + if( $t_inherit ) { $t_project_ids = project_hierarchy_inheritance( $p_project_id ); } else { @@ -416,33 +416,23 @@ function version_get_all_rows( $p_project_id, $p_released = null, $p_obsolete = } $t_is_cached = true; - foreach ($t_project_ids as $t_project_id ) { - if( !isset( $g_cache_versions_project[ (int)$t_project_id ] ) ) { + foreach( $t_project_ids as $t_project_id ) { + if( !isset( $g_cache_versions_project[$t_project_id] ) ) { $t_is_cached = false; + break; } } - if( $t_is_cached ) { + if( $t_is_cached ) { $t_versions = array(); - foreach ($t_project_ids as $t_project_id ) { - if( !empty( $g_cache_versions_project[ (int)$t_project_id ]) ) { - foreach( $g_cache_versions_project[ (int)$t_project_id ] as $t_id ) { + foreach( $t_project_ids as $t_project_id ) { + if( !empty( $g_cache_versions_project[$t_project_id]) ) { + foreach( $g_cache_versions_project[$t_project_id] as $t_id ) { $t_versions[] = version_cache_row( $t_id ); } } } return $t_versions; } - -# if( isset( $g_cache_versions_project[ (int)$p_project_id ] ) ) { -# if( !empty( $g_cache_versions_project[ (int)$p_project_id ]) ) { -# foreach( $g_cache_versions_project[ (int)$p_project_id ] as $t_id ) { -# $t_versions[] = version_cache_row( $t_id ); -# } -# return $t_versions; -# } else { -# return array(); -# } -# } $c_project_id = db_prepare_int( $p_project_id ); $t_project_version_table = db_get_table( 'mantis_project_version_table' ); @@ -489,7 +479,7 @@ function version_get_all_rows( $p_project_id, $p_released = null, $p_obsolete = * @param int $p_released * @param bool $p_obsolete * @return array - */ + */ function version_get_all_rows_with_subs( $p_project_id, $p_released = null, $p_obsolete = false ) { $t_project_where = helper_project_specific_where( $p_project_id ); @@ -653,7 +643,7 @@ function version_get( $p_version_id ) { * Return a copy of the version structure with all the instvars prepared for db insertion * @param VersionData $p_version_info * @return VersionData - */ + */ function version_prepare_db( $p_version_info ) { $p_version_info->id = db_prepare_int( $p_version_info->id ); $p_version_info->project_id = db_prepare_int( $p_version_info->project_id );