From: <gi...@ma...> - 2010-01-17 03:54:18
|
The branch, master-1.2.x has been updated via dd258c75542e7bb090a9e274be37f438a65c5eb9 (commit) from d6b2fd0939ad3e7172879da76d1559c3db9964fb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit dd258c75542e7bb090a9e274be37f438a65c5eb9 Author: David Hicks <hic...@op...> Date: Sun Jan 17 14:49:40 2010 +1100 Fix #11402: Project hierarchy cache problem on manage_proj_edit_page.php manage_proj_edit_page.php didn't cache project hierarchies with disabled projects included. Thus errors relating to in_array() were seen when attempting to edit a parent project when one of the sub-projects was marked as being disabled. ----------------------------------------------------------------------- Summary of changes: core/project_hierarchy_api.php | 60 +++++++++++++++++++++++---------------- manage_proj_edit_page.php | 4 +- 2 files changed, 37 insertions(+), 27 deletions(-) ----------------------------------------------------------------------- commit dd258c75542e7bb090a9e274be37f438a65c5eb9 Author: David Hicks <hic...@op...> Date: Sun Jan 17 14:49:40 2010 +1100 Fix #11402: Project hierarchy cache problem on manage_proj_edit_page.php manage_proj_edit_page.php didn't cache project hierarchies with disabled projects included. Thus errors relating to in_array() were seen when attempting to edit a parent project when one of the sub-projects was marked as being disabled. diff --git a/core/project_hierarchy_api.php b/core/project_hierarchy_api.php index 2a667d0..5188080 100644 --- a/core/project_hierarchy_api.php +++ b/core/project_hierarchy_api.php @@ -30,9 +30,9 @@ $g_cache_show_disabled = null; /** * Add project to project hierarchy - * @param int $p_child_id - * @param int $p_parent_id - * @param bool $p_inherit_parent + * @param int $p_child_id Child project ID + * @param int $p_parent_id Parent project ID + * @param bool $p_inherit_parent Whether or not the child project inherits from the parent project * @return null */ function project_hierarchy_add( $p_child_id, $p_parent_id, $p_inherit_parent = true ) { @@ -56,9 +56,9 @@ function project_hierarchy_add( $p_child_id, $p_parent_id, $p_inherit_parent = t /** * Update project hierarchy - * @param int $p_child_id - * @param int $p_parent_id - * @param bool $p_inherit_parent + * @param int $p_child_id Child project ID + * @param int $p_parent_id Parent project ID + * @param bool $p_inherit_parent Whether or not the child project inherits from the parent project * @return null */ function project_hierarchy_update( $p_child_id, $p_parent_id, $p_inherit_parent = true ) { @@ -77,8 +77,8 @@ function project_hierarchy_update( $p_child_id, $p_parent_id, $p_inherit_parent /** * Remove project from project hierarchy - * @param int $p_child_id - * @param int $p_parent_id + * @param int $p_child_id Child project ID + * @param int $p_parent_id Parent project ID * @return null */ function project_hierarchy_remove( $p_child_id, $p_parent_id ) { @@ -96,7 +96,7 @@ function project_hierarchy_remove( $p_child_id, $p_parent_id ) { /** * Remove any project hierarchy entries relating to project_id - * @param int $p_project_id + * @param int $p_project_id Project ID * @return null */ function project_hierarchy_remove_all( $p_project_id ) { @@ -113,14 +113,15 @@ function project_hierarchy_remove_all( $p_project_id ) { /** * Returns true if project is at top of hierarchy - * @param bool $p_project_id + * @param bool $p_project_id Project ID + * @param bool $p_show_disabled Whether or not to consider projects which are disabled * @return bool */ -function project_hierarchy_is_toplevel( $p_project_id ) { +function project_hierarchy_is_toplevel( $p_project_id, $p_show_disabled = false ) { global $g_cache_project_hierarchy; - if( null === $g_cache_project_hierarchy ) { - project_hierarchy_cache(); + if( ( null === $g_cache_project_hierarchy ) || ( $p_show_disabled ) ) { + project_hierarchy_cache( $p_show_disabled ); } if( isset( $g_cache_project_hierarchy[ALL_PROJECTS] ) ) { @@ -131,8 +132,8 @@ function project_hierarchy_is_toplevel( $p_project_id ) { } /** - * cache project hierarchy - * @param bool $p_show_disabled + * Cache project hierarchy + * @param bool $p_show_disabled Whether or not to cache projects which are disabled * @return bool */ function project_hierarchy_cache( $p_show_disabled = false ) { @@ -191,26 +192,35 @@ function project_hierarchy_cache( $p_show_disabled = false ) { /** * Returns true if the child project inherits categories from the parent. - * @param int $p_child_id - * @param int $p_parent_id - * @todo what happens if cache isn't populated? + * @param int $p_child_id Child project ID + * @param int $p_parent_id Parent project ID + * @param bool $p_show_disabled Whether or not to consider projects which are disabled * @return bool */ -function project_hierarchy_inherit_parent( $p_child_id, $p_parent_id ) { +function project_hierarchy_inherit_parent( $p_child_id, $p_parent_id, $p_show_disabled = false ) { global $g_cache_project_inheritance; + if( ( null === $g_cache_project_inheritance ) || ( $p_show_disabled ) ) { + project_hierarchy_cache( $p_show_disabled ); + } + return in_array( $p_parent_id, $g_cache_project_inheritance[$p_child_id] ); } /** * Generate an array of project's the given project inherits from, * including the original project in the result. - * @param int $p_project_id + * @param int $p_project_id Project ID + * @param bool $p_show_disabled Whether or not to consider projects which are disabled * @return array */ -function project_hierarchy_inheritance( $p_project_id ) { +function project_hierarchy_inheritance( $p_project_id, $p_show_disabled = false ) { global $g_cache_project_inheritance; + if( ( null === $g_cache_project_inheritance ) || ( $p_show_disabled ) ) { + project_hierarchy_cache( $p_show_disabled ); + } + $t_project_ids = array( (int) $p_project_id, ); @@ -241,14 +251,14 @@ function project_hierarchy_inheritance( $p_project_id ) { /** * Get subprojects for a project - * @param int $p_project_id - * @param bool $p_show_disabled + * @param int $p_project_id Project ID + * @param bool $p_show_disabled Whether or not to consider projects which are disabled * @return array */ function project_hierarchy_get_subprojects( $p_project_id, $p_show_disabled = false ) { global $g_cache_project_hierarchy; - if(( null === $g_cache_project_hierarchy ) || ( $p_show_disabled ) ) { + if( ( null === $g_cache_project_hierarchy ) || ( $p_show_disabled ) ) { project_hierarchy_cache( $p_show_disabled ); } @@ -261,7 +271,7 @@ function project_hierarchy_get_subprojects( $p_project_id, $p_show_disabled = fa /** * Get complete subproject hierarchy for a project - * @param int $p_project_id + * @param int $p_project_id Project ID * @return array */ function project_hierarchy_get_all_subprojects( $p_project_id ) { diff --git a/manage_proj_edit_page.php b/manage_proj_edit_page.php index f7f6428..36e91b9 100644 --- a/manage_proj_edit_page.php +++ b/manage_proj_edit_page.php @@ -195,7 +195,7 @@ if ( access_has_global_level ( config_get( 'delete_project_threshold' ) ) ) { ?> <?php echo form_security_field( 'manage_proj_update_children' ) ?> <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> <?php - project_hierarchy_cache(); + project_hierarchy_cache( true ); $t_subproject_ids = current_user_get_accessible_subprojects( $f_project_id, /* show_disabled */ true ); if ( Array() != $t_subproject_ids ) { @@ -227,7 +227,7 @@ if ( access_has_global_level ( config_get( 'delete_project_threshold' ) ) ) { ?> <?php foreach ( $t_subproject_ids as $t_subproject_id ) { $t_subproject = project_get_row( $t_subproject_id ); - $t_inherit_parent = project_hierarchy_inherit_parent( $t_subproject_id, $f_project_id ); + $t_inherit_parent = project_hierarchy_inherit_parent( $t_subproject_id, $f_project_id, true ); ?> <tr <?php echo helper_alternate_class() ?>> <td> ----------------------------------------------------------------------- -- Mantis Bug Tracker |