From: Victor B. <vb...@us...> - 2007-04-01 08:03:42
|
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3482 Modified Files: custom_field_api.php history_api.php Log Message: Fixed #7875: Port 7774: custom fields not stored correctly in bug history Index: history_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/history_api.php,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- history_api.php 6 Mar 2007 07:05:19 -0000 1.39 +++ history_api.php 1 Apr 2007 08:03:27 -0000 1.40 @@ -1,7 +1,7 @@ <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... - # Copyright (C) 2002 - 2004 Mantis Team - man...@li... + # Copyright (C) 2002 - 2007 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details @@ -102,12 +102,14 @@ # Retrieves the raw history events for the specified bug id and returns it in an array # The array is indexed from 0 to N-1. The second dimension is: 'date', 'userid', 'username', # 'field','type','old_value','new_value' - function history_get_raw_events_array( $p_bug_id, $p_user_id=NULL ) { + function history_get_raw_events_array( $p_bug_id, $p_user_id = null ) { $t_mantis_bug_history_table = config_get( 'mantis_bug_history_table' ); $t_mantis_user_table = config_get( 'mantis_user_table' ); $t_history_order = config_get( 'history_order' ); $c_bug_id = db_prepare_int( $p_bug_id ); - $t_user_id = ( NULL === $p_user_id ) ? auth_get_current_user_id() : $p_user_id; + + $t_user_id = ( ( null === $p_user_id ) ? auth_get_current_user_id() : $p_user_id ); + $t_roadmap_view_access_level = config_get( 'roadmap_view_threshold' ); # grab history and display by date_modified then field_name @@ -133,8 +135,8 @@ extract( $row, EXTR_PREFIX_ALL, 'v' ); // check that the item should be visible to the user - // custom fields - $t_field_id = custom_field_get_id_from_name( $v_field_name ); + // custom fields - we are passing 32 here to notify the API that the custom field name is truncated by the history column from 64 to 32 characters. + $t_field_id = custom_field_get_id_from_name( $v_field_name, 32 ); if ( false !== $t_field_id && !custom_field_has_read_access( $t_field_id, $p_bug_id, $t_user_id ) ) { continue; @@ -154,6 +156,7 @@ continue; } } + if ( $v_type == BUGNOTE_STATE_CHANGED ) { if ( !$t_private_bugnote_visible && ( bugnote_get_field( $v_new_value, 'view_state' ) == VS_PRIVATE ) ) { @@ -161,6 +164,7 @@ } } } + $raw_history[$j]['date'] = db_unixtimestamp( $v_date_modified ); $raw_history[$j]['userid'] = $v_user_id; @@ -171,6 +175,7 @@ $raw_history[$j]['type'] = $v_type; $raw_history[$j]['old_value'] = $v_old_value; $raw_history[$j]['new_value'] = $v_new_value; + $j++; } # end for loop Index: custom_field_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/custom_field_api.php,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- custom_field_api.php 6 Mar 2007 07:05:19 -0000 1.61 +++ custom_field_api.php 1 Apr 2007 08:03:27 -0000 1.62 @@ -1,7 +1,7 @@ <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... - # Copyright (C) 2002 - 2004 Mantis Team - man...@li... + # Copyright (C) 2002 - 2007 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details @@ -588,12 +588,20 @@ # -------------------- # Get the id of the custom field with the specified name. # false is returned if no custom field found with the specified name. - function custom_field_get_id_from_name( $p_field_name ) { + function custom_field_get_id_from_name( $p_field_name, $p_truncated_length = null ) { $t_custom_field_table = config_get( 'mantis_custom_field_table' ); $c_field_name = db_prepare_string( $p_field_name ); - $query = "SELECT id FROM $t_custom_field_table WHERE name = '$c_field_name'"; + if ( ( null === $p_truncated_length ) || ( strlen( $c_field_name ) != $p_truncated_length ) ) { + $query = "SELECT id FROM $t_custom_field_table WHERE name = '$c_field_name'"; + } else { + # @@@ This is to handle the case where we only have a truncated part of the name. This happens in the case where + # we are getting the custom field name from the history logs, since history is 32 and custom field name is 64. + # This fix will handle entries already in the database, future entries should be handled by making the field name max lengths match. + $query = "SELECT id FROM $t_custom_field_table WHERE name LIKE '$c_field_name%'"; + } + $t_result = db_query( $query, 1 ); if ( db_num_rows( $t_result ) == 0 ) { @@ -610,7 +618,7 @@ # # The ids will be sorted based on the sequence number associated with the binding function custom_field_get_linked_ids( $p_project_id = ALL_PROJECTS ) { - global $g_cache_cf_linked; + global $g_cache_cf_linked; if ( ! isset( $g_cache_cf_linked[$p_project_id] ) ) { |