View Issue Details

IDProjectCategoryView StatusLast Update
0004220Plugin - CsvImportGeneralpublic2020-07-30 03:24
Reporterfusenigk Assigned Tovboctor  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0004220: * Import new Issues from file
Description

I found some php file extensions for the possibility to import new issues from an external file. These feature is developed by cas@nuy.info, but works for me and me 0.19.a2 installation.
Is someone interested in this extension?

Tagspatch
Attached Files
Mantis_import.zip (5,283 bytes)
mantis_import_issues.zip (10,585 bytes)
import_issues.php (22,471 bytes)   
<?php
	# Mantis - a php based bugtracking system
	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
	# This program is distributed under the terms and conditions of the GPL
	# See the README and LICENSE files for details

	# --------------------------------------------------------
	# $Id: import_issues.php  2005/11/04 10:23  gtomlin
	# --------------------------------------------------------
  #
  # Changes
  # 03.03.06 / mgfeller (changes marked by @@@ mgf)
  # 
?>
<?php
	require_once( 'core.php' ) ;

	$t_core_path = config_get( 'core_path' );

	require_once( $t_core_path.'custom_field_api.php' );

	html_page_top1() ;
	html_page_top2() ;

	# get submitted data - input file characteristics.
	# $f_import_file		= gpc_get_string( 'import_file' );
	$f_import_file		= gpc_get_file( 'import_file' );
	echo '<p>' . lang_get( 'importing_from' ) . $f_import_file['name'] . '</p >';
	$f_fieldlim			= gpc_get_string( 'fieldlim' );
	$f_linelim			= gpc_get_string( 'linelim' );
	$f_client			= gpc_get_bool( 'client' );

	# get submitted data - target project id.
	# go no further if current project is "All Projects".
	$t_project_id		= helper_get_current_project();
	if ( $t_project_id == ALL_PROJECTS ) {
		echo '<p>' . lang_get( 'import_reject_all_projects' ) . project_get_name( $t_project_id ) . '.</p>';
		html_page_bottom1( __FILE__ );
		return;
	}
	echo '<p>' . lang_get( 'importing_into_project' ) . project_get_name( $t_project_id ) . '</p>';

	# get submitted data - column data sources.
	$f_reporterx		= gpc_get_int( 'reporter' );
	$f_const_reporter	= gpc_get_int( 'const_reporter', auth_get_current_user_id() );

	$f_handlerx			= gpc_get_int( 'handler' );
	$f_const_handler	= gpc_get_int( 'const_handler', 0 );

	$f_priorityx		= gpc_get_int( 'priority' );
	$f_const_priority	= gpc_get_int( 'const_priority', config_get( 'default_bug_priority' ) );

	$f_severityx		= gpc_get_int( 'severity' );
	$f_const_severity	= gpc_get_int( 'const_severity', config_get( 'default_bug_severity' ) );

	$f_reproducibilityx	= gpc_get_int( 'reproducibility' );
	$f_const_reproducibility  = gpc_get_int( 'const_reproducibility', 0 );

	$f_statusx		= gpc_get_int( 'status' );
	$f_const_status	= gpc_get_int( 'const_status', config_get( 'bug_submit_status' ) );

	$f_resolutionx		= gpc_get_int( 'resolution' );
	$f_const_resolution	= gpc_get_int( 'const_resolution', OPEN );

	$f_categoryx		= gpc_get_int( 'category' );
	$f_const_category	= gpc_get_string( 'const_category', '' );

	$f_date_submittedx	= gpc_get_int( 'date_submitted' );
	$f_const_date_submitted	= gpc_get_string( 'const_date_submitted', '' );

	$f_osx				= gpc_get_int( 'os' );
	$f_const_os			= gpc_get_string( 'const_os' );

	$f_os_buildx		= gpc_get_int( 'os_build' );
	$f_const_os_build	= gpc_get_string( 'const_os_build' );

	$f_platformx		= gpc_get_int( 'platform' );
	$f_const_platform	= gpc_get_string( 'const_platform' );

	$f_versionx			= gpc_get_int( 'version' );
	$f_const_version	= gpc_get_string( 'const_version' );

	$f_fixed_in_versionx = gpc_get_int( 'fixed_in_version' );
	$f_const_fixed_in_version  = gpc_get_string( 'const_fixed_in_version' );

	$f_buildx			= gpc_get_int( 'build' );
	$f_const_build		= gpc_get_string( 'const_build' );

	$f_view_statex		= gpc_get_int( 'view_state' );
	$f_const_view_state	= gpc_get_int( 'const_view_state', config_get( 'default_bug_view_status' ) );

	$f_summaryx			= gpc_get_int( 'summary' );

	$f_descriptionx		= gpc_get_int( 'description' );
	$f_const_description	= gpc_get_string( 'const_description' );

	$f_steps_to_reproducex	= gpc_get_int( 'steps_to_reproduce' );
	$f_const_steps_to_reproduce  = gpc_get_string( 'const_steps_to_reproduce' );

	$f_additional_informationx = gpc_get_int( 'additional_information' );
	$f_const_additional_information  = gpc_get_string( 'const_additional_information' );

	# check completeness
	if ( is_blank( $f_import_file['tmp_name'] ) || ( $f_import_file['size'] == 0 ) || is_blank( $f_fieldlim ) || is_blank( $f_linelim ) ) {
		trigger_error( ERROR_EMPTY_FIELD, ERROR );
	}

	$t_related_custom_field_ids = custom_field_get_linked_ids( $t_project_id );
	foreach( $t_related_custom_field_ids as $t_id ) {
		$t_def = custom_field_get_definition( $t_id );
		if ( ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_USE_CONST_VALUE ) && ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) ) {
			error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
			trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
		}
	}

	# build column list for import
	$t_column_array = array();
	$t_column_count = 0;

	if ( $f_reporterx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'reporter';
	}

	if ( $f_handlerx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'handler';
	}

	if ( $f_priorityx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'priority';
	}

	if ( $f_severityx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'severity';
	}

	if ( $f_reproducibilityx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'reproducibility';
	}

	if ( $f_statusx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'status';
	}

	if ( $f_resolutionx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'resolution';
	}

	if ( $f_categoryx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'category';
	}

	if ( $f_date_submittedx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'date_submitted';
	}

	if ( $f_osx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'os';
	}

	if ( $f_os_buildx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'os_build';
	}

	if ( $f_platformx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'platform';
	}

	if ( $f_versionx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'version';
	}

	if ( $f_fixed_in_versionx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'fixed_in_version';
	}

	if ( $f_buildx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'build';
	}

	if ( $f_view_statex == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'view_state';
	}

	if ( $f_summaryx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'summary';
	}

	if ( $f_descriptionx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'description';
	}

	if ( $f_steps_to_reproducex == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'reproduce';
	}

	if ( $f_additional_informationx == IMPORT_FROM_FILE ) {
		$t_column_array[$t_column_count++] = 'info';
	}

	foreach( $t_related_custom_field_ids as $t_id ) {
		if ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_FROM_FILE ) {
			$t_column_array[$t_column_count++] = "custom_field_$t_id";
		}
	}

	$t_column_list = "(" . implode ( "," , $t_column_array ) . ")";
	echo '<p>' . lang_get( 'importing_columns' ) . $t_column_list . '</p>';


	# drop import table if it remains from a previous import attempt
	# (may wind up with duplicate records otherwise).
	$t_mantis_import_issues_table = config_get( 'db_table_prefix' ) . '_import_issues' . config_get( 'db_table_suffix' );
	$query = 'DROP TABLE IF EXISTS ' . $t_mantis_import_issues_table;
	db_query( $query );

	# create temporary table for uploading data.
	$query = 'CREATE TABLE ' . $t_mantis_import_issues_table . '(' .
		'reporter VARCHAR(32)' .
		', handler VARCHAR(32)' .
		', priority VARCHAR(32)' .
		', severity VARCHAR(32)' .
		', reproducibility VARCHAR(32)' .
		', status VARCHAR(32)' .
		', resolution VARCHAR(32)' .
		', category VARCHAR(64)' .
		', date_submitted DATETIME' .
		', os VARCHAR(32)' .
		', os_build VARCHAR(32)' .
		', platform VARCHAR(32)' .
		', version VARCHAR(64)' .
		', fixed_in_version VARCHAR(64)' .
		', build VARCHAR(32)' .
		', view_state VARCHAR(64)' .
		', summary VARCHAR(128)' .
		', description TEXT' .
		', reproduce TEXT' .
		', info TEXT' ;

	foreach( $t_related_custom_field_ids as $t_id ) {
		$query .= ", custom_field_$t_id VARCHAR(255)" ;
	}

	$query .= ' ) ';

	db_query( $query );

	$c_import_file = db_prepare_string( $f_import_file['tmp_name'] );
	$c_fieldlim = db_prepare_string( $f_fieldlim );

	if ( $f_linelim == '\r' )
		$c_linelim = '\r';
	else if ( $f_linelim == '\n' )
		$c_linelim = '\n';
	else
		$c_linelim = '\r\n';

	# upload data into temporary table.
	if ( $f_client ) {
		$query = 'LOAD DATA INFILE ';
	} else {
		$query = 'LOAD DATA LOCAL INFILE ';
	}
	$query .= '"';
	$query .= $c_import_file ;
	$query .= '"';
	$query .= ' REPLACE INTO TABLE  ' . $t_mantis_import_issues_table . ' FIELDS TERMINATED BY  ' ;
	$query .= '"';
	$query .= $c_fieldlim ;
	$query .= '"';
	$query .= ' LINES TERMINATED BY ';
	$query .= '"';
	$query .= $c_linelim ;
	$query .= '" ';
	$query .= $t_column_list ;
	$query .= ";";

	db_query( $query );

	# do actual importing here:
	# for each row in temporary table,
	# - construct a BugData object
	# - use bug_create to create a new issue.

	$t_bug_count			= 0;
	$t_success_count		= 0;
	$t_error_count			= 0;

	$query = 'SELECT * FROM  ' . $t_mantis_import_issues_table;
	$result = db_query( $query );
  $num_rows = db_num_rows($result);       # @@@ mgf: inserted
  # print_r($num_rows);                     # @@@ mgf: inserted to test
	for ($i=0;$i<$num_rows;$i++) {          # @@@ mgf: inserted
	# while ( $t_row = db_fetch_array( $result ) ) { # @@@ mgf: use $num_files instead of this line and fudge below
		# @@@ note: the following ugly fudge is present to catch the end of file - gtomlin
		# if ( in_array( chr( 26 ), $t_row ) ) # @@@ mgf: commented out
		#	break;                               # @@@ mgf: commented out

    # echo($i);                              # @@@ mgf: inserted to test
    $t_row = db_fetch_array( $result );    # @@@ mgf: inserted
    # print_r($t_row);                       # @@@ mgf: inserted to test
		$t_bug_count++;

/*	# @@@ mgf: replaced all numerical indices into $t_row by actual keys
    # @@@ mgf: custom fields must then be treated differently also, see below
    $t_col = 0;
		$t_reporter = $t_row[$t_col++];
		$t_handler = $t_row[$t_col++];
		$t_priority = $t_row[$t_col++];
		$t_severity = $t_row[$t_col++];
		$t_reproducibility = $t_row[$t_col++];
		$t_status = $t_row[$t_col++];
		$t_resolution = $t_row[$t_col++];
		$t_category = $t_row[$t_col++];
		$t_date_submitted = $t_row[$t_col++];
		$t_os = $t_row[$t_col++];
		$t_os_build = $t_row[$t_col++];
		$t_platform = $t_row[$t_col++];
		$t_version = $t_row[$t_col++];
		$t_fixed_in_version = $t_row[$t_col++];
		$t_build = $t_row[$t_col++];
		$t_view_state = $t_row[$t_col++];
		$t_summary = $t_row[$t_col++];
		$t_description = $t_row[$t_col++];
		$t_steps_to_reproduce = $t_row[$t_col++];
		$t_additional_information = $t_row[$t_col++];
*/
    
		$t_reporter = $t_row['reporter'];
		$t_handler = $t_row['handler'];
		$t_priority = $t_row['priority'];
		$t_severity = $t_row['severity'];
		$t_reproducibility = $t_row['reproducibility'];
		$t_status = $t_row['status'];
		$t_resolution = $t_row['resolution'];
		$t_category = $t_row['category'];
		$t_date_submitted = $t_row['date_submitted'];
		$t_os = $t_row['os'];
		$t_os_build = $t_row['os_build'];
		$t_platform = $t_row['platform'];
		$t_version = $t_row['version'];
		$t_fixed_in_version = $t_row['fixed_in_version'];
		$t_build = $t_row['build'];
		$t_view_state = $t_row['view_state'];
		$t_summary = $t_row['summary'];
		$t_description = $t_row['description'];
		$t_steps_to_reproduce = $t_row['reproduce'];
		$t_additional_information = $t_row['info'];
    
		# this number should reflect the number of standard columns, this is used later to calculate # @@@ mgf: no, key is now used
		# the index of the first custom field.                                                       # @@@ mgf: no, key is now used
		# $t_num_of_columns = $t_col;                                                                # @@@ mgf: no, this is not used anymore, see below

		if ( is_blank( $t_description ) ) {
			$t_description = $t_summary;
		}

		# Fill the fields for uploading

		# Set up reporter_id (if value is from file must translate from string to id)
		if ( $f_reporterx == IMPORT_FROM_FILE ) {
			$t_reporter_id = user_get_id_by_name( $t_reporter );
		} else if ( $f_reporterx == IMPORT_USE_CONST_VALUE ) {
			$t_reporter_id = $f_const_reporter;
		} else {
			$t_reporter_id = 1 ;
		}

		# Set up handler_id (if value is from file must translate from string to id)
		if ( $f_handlerx == IMPORT_FROM_FILE ) {
			$t_handler_id = user_get_id_by_name( $t_handler );
		} else if ( $f_handlerx == IMPORT_USE_CONST_VALUE ) {
			$t_handler_id = $f_const_handler;
		} else {
			$t_handler_id = 0 ;
		}

		# Set up duplicate_id (hard coded since it's the
		# ID of another bug, which could be in import stream so we will not know its ID).
		$t_duplicate_id = 0;

		# Set up priority (if value is from file must translate from string to id)
		if ( $f_priorityx == IMPORT_FROM_FILE ) {
			$t_priority = get_string_to_enum( 'priority', $t_priority );
		} else if ( $f_priorityx == IMPORT_USE_CONST_VALUE ) {
			$t_priority = $f_const_priority;
		} else {
			$t_priority = config_get( 'default_bug_priority' ) ;
		}

		# Set up severity (if value is from file must translate from string to id)
		if ( $f_severityx == IMPORT_FROM_FILE ) {
			$t_severity = get_string_to_enum( 'severity', $t_severity );
		} else if ( $f_severityx == IMPORT_USE_CONST_VALUE ) {
			$t_severity = $f_const_severity;
		} else {
			$t_severity = config_get( 'default_bug_severity' ) ;
		}

		# Set up reproducibility (if value is from file must translate from string to id)
		if ( $f_reproducibilityx == IMPORT_FROM_FILE ) {
			$t_reproducibility = get_string_to_enum( 'reproducibility', $t_reproducibility );
		} else if ( $f_reproducibilityx == IMPORT_USE_CONST_VALUE ) {
			$t_reproducibility = $f_const_reproducibility;
		} else {
			$t_reproducibility = 10 ;
		}

		# Set up status (if value is from file must translate from string to id)
		if ( $f_statusx == IMPORT_FROM_FILE ) {
			$t_status = get_string_to_enum( 'status', $t_status );
		} else if ( $f_statusx == IMPORT_USE_CONST_VALUE ) {
			$t_status = $f_const_status;
		} else {
			$t_status = config_get( 'bug_submit_status' ) ;
		}

		# Default resolution - bug_create will set value
		if ( $f_resolutionx == IMPORT_FROM_FILE ) {
			$t_resolution = get_string_to_enum( 'resolution', $t_resolution );
		} else if ( $f_resolutionx == IMPORT_USE_CONST_VALUE ) {
			$t_resolution = $f_const_resolution;
		} else {
			$t_resolution = OPEN ;
		}

		# Default projection - bug_create will set value
		$t_projection = 10 ;

		# Set up category
		# @@@ should not really trust value from file here! (gtomlin)
		if ( $f_categoryx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_categoryx == IMPORT_USE_CONST_VALUE ) {
			$t_category = $f_const_category;
		} else {
			$t_category = '' ;
		}

		# Date fields. Last updated is set to now by bug_create
		if ( $f_date_submittedx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_date_submittedx == IMPORT_USE_CONST_VALUE ) {
			$t_date_submitted = $f_const_date_submitted;
		} else {
			$t_date_submitted = '' ;
		}
		$t_last_updated = '';

		# Default eta - bug_create will set value
		$t_eta = 10 ;

		# Set up os
		if ( $f_osx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_osx == IMPORT_USE_CONST_VALUE ) {
			$t_os = $f_const_os;
		} else {
			$t_os = '' ;
		}

		# Set up os_build
		if ( $f_os_buildx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_os_buildx == IMPORT_USE_CONST_VALUE ) {
			$t_os_build = $f_const_os_build;
		} else {
			$t_os_build = '';
		}

		# Set up platform
		if( $f_platformx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_platformx == IMPORT_USE_CONST_VALUE ) {
			$t_platform = $f_const_platform;
		} else {
			$t_platform = '' ;
		}

		# Set up version (should not really trust value from file here)
		if ( $f_versionx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_versionx == IMPORT_USE_CONST_VALUE ) {
			$t_version = $f_const_version;
		} else {
			$t_version = '' ;
		}

		# Set up fixed_in_version (should not really trust value from file here)
		if ( $f_fixed_in_versionx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_fixed_in_versionx == IMPORT_USE_CONST_VALUE ) {
			$t_fixed_in_version = $f_const_fixed_in_version;
		} else {
			$t_fixed_in_version = '' ;
		}

		# Set up build
		if( $f_buildx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_buildx == IMPORT_USE_CONST_VALUE ) {
			$t_build = $f_const_build;
		} else {
			$t_build = '' ;
		}

		# Set up view state
		if( $f_view_statex == IMPORT_FROM_FILE ) {
			$t_view_state = get_string_to_enum( 'view_state', $t_view_state );
		} else if ( $f_buildx == IMPORT_USE_CONST_VALUE ) {
			$t_view_state = $f_const_view_state;
		} else {
			$t_view_state = config_get( 'default_bug_view_status' ) ;
		}

		# Defaulting sponsorship for now.
		$t_sponsorship_total = 0;

		# Set up description
		if( $f_descriptionx == IMPORT_FROM_FILE ) {
			# do nothing
		} else {
			$t_description = $f_const_description;
		}

		# Set up steps to reproduce
		if( $f_steps_to_reproducex == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_steps_to_reproducex == IMPORT_USE_CONST_VALUE ) {
			$t_steps_to_reproduce = $f_const_steps_to_reproduce;
		} else {
			$t_steps_to_reproduce = '';
		}

		# Set up additional information
		if( $f_additional_informationx == IMPORT_FROM_FILE ) {
			# do nothing
		} else if ( $f_additional_informationx == IMPORT_USE_CONST_VALUE ) {
			$t_additional_information = $f_const_additional_information;
		} else {
			$t_additional_information = '' ;
		}

		# Defaulting profile_id for now.
		$t_profile_id = 0;

		# Create the bug
		$t_bug_data = new BugData;
		$t_bug_data->project_id				= $t_project_id;
		$t_bug_data->reporter_id			= $t_reporter_id;
		$t_bug_data->handler_id				= $t_handler_id;
		$t_bug_data->duplicate_id			= $t_duplicate_id;
		$t_bug_data->priority				= $t_priority;
		$t_bug_data->severity				= $t_severity;
		$t_bug_data->reproducibility		= $t_reproducibility;
		$t_bug_data->status					= $t_status;
		$t_bug_data->resolution				= $t_resolution;
		$t_bug_data->projection				= $t_projection;
		$t_bug_data->category				= $t_category;
		$t_bug_data->date_submitted			= $t_date_submitted;
		$t_bug_data->last_updated			= $t_last_updated;
		$t_bug_data->eta					= $t_eta;
		$t_bug_data->os						= $t_os;
		$t_bug_data->os_build				= $t_os_build;
		$t_bug_data->platform				= $t_platform;
		$t_bug_data->version				= $t_version;
		$t_bug_data->fixed_in_version		= $t_fixed_in_version;
		$t_bug_data->build					= $t_build;
		$t_bug_data->view_state				= $t_view_state;
		$t_bug_data->summary				= $t_summary;
		$t_bug_data->description			= $t_description;
		$t_bug_data->steps_to_reproduce		= $t_steps_to_reproduce;
		$t_bug_data->additional_information	= $t_additional_information;
		$t_bug_data->profile_id				= $t_profile_id;
		$t_bug_data->sponsorship_total		= $t_sponsorship_total;

		$t_bug_id = bug_create($t_bug_data);
		if ( $t_bug_id ) {
			$t_error = false;

			# Setting status
			if ( $t_bug_data->status != config_get( 'bug_submit_status' ) ) {
				bug_set_field( $t_bug_id, 'status', $t_bug_data->status );
			}

			# Setting resolution
			if ( $t_bug_data->resolution != OPEN ) {
				bug_set_field( $t_bug_id, 'resolution', $t_bug_data->resolution );
			}

			# Setting fixed_in_version
			if ( $t_bug_data->fixed_in_version != '' ) {
				bug_set_field( $t_bug_id, 'fixed_in_version', $t_bug_data->fixed_in_version );
			}

			# Setting date fields
			if ( $t_bug_data->date_submitted != '' ) {
				bug_set_field( $t_bug_id, 'date_submitted', $t_bug_data->date_submitted );
			}

			# Adding custom fields
			$t_custom_field_count = 0;

			foreach( $t_related_custom_field_ids as $t_id ) {
				$t_custom_field_count++;

				$t_def = custom_field_get_definition( $t_id );

				if ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_FROM_FILE ) {
					# $t_custom_field_value = $t_row[ $t_num_of_columns - 1 + $t_custom_field_count ]; # @@@ mgf: commented out
          $t_custom_field_value = $t_row[ "custom_field_$t_id" ];                            # @@@ mgf: inserted
				}
				else if ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_USE_CONST_VALUE ) {
					$t_custom_field_value = gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] );
				}
				else {
					continue;
				}
				# August 2006 - mBernigaud : don't set empty date -->
				if ( $t_custom_field_value != '') {
					# August 2006 - mBernigaud : Convert string date to its internal value				
					if ( $t_def['type'] == CUSTOM_FIELD_TYPE_DATE ) {
						$t_custom_field_value = strtotime( $t_custom_field_value ) ;
					}		
					if( !custom_field_set_value( $t_id, $t_bug_id, $t_custom_field_value ) ) {
						echo '<p>' . lang_get( 'import_custom_field_failure' ) . $t_def['name'] . ' : ' . $t_summary . '</p >';
						$t_error_count++;
						$t_error = true;
					}
				}
			}

			if ( !$t_error ) {
				echo '<p>' . lang_get( 'import_success' ) . $t_bug_id . ": " . $t_summary . '</p>';
				$t_success_count++;
			}
		}
		else {
			echo '<p>' . lang_get( 'import_failure' ) . $t_summary . '</p>';
			$t_error_count++;
		}
	}

	#echo '<p>' . lang_get( 'import_completed' ) . $t_error_count . '</p>';
	echo '<p>' . lang_get( 'import_completed_1' ) . $t_success_count . lang_get( 'import_completed_2' ) . $t_error_count . '</p>';

	# remove temporary import table
	$query = 'DROP TABLE IF EXISTS  ' . $t_mantis_import_issues_table;
	db_query( $query );

	html_page_bottom1( __FILE__ );

	#-----------------------
	# get_string_to_enum:
	# arg: enum name, string value
	# return: enum value
	#-----------------------
	function get_string_to_enum( $p_enum_name, $p_value ) {
		$t_config_var_name = $p_enum_name.'_enum_string';
		#$t_config_var_value = config_get( $t_config_var_name );
		$t_config_var_value = lang_get( $t_config_var_name );
		$t_arr  = explode_enum_string( $t_config_var_value );
		$t_enum_count = count( $t_arr );
		for ( $i = 0; $i < $t_enum_count; $i++ ) {
			$t_elem  = explode_enum_arr( $t_arr[$i] );
			if ( $t_elem[1] == $p_value ) {
				return $t_elem[0];
			}
		} # end for
		return 0;
	}
?>
import_issues.php (22,471 bytes)   
csv_import-1.0.tgz (7,213 bytes)
csv_import-1.0.1.zip (14,981 bytes)
Csv_import110.zip (11,786 bytes)
strings_german.txt (2,140 bytes)   
<?php

# Custom strings for german language
$s_csv_import_title		= "Mantis CSV Import Probleme" ;
$s_csv_import_config	= "Konfiguration" ;
$s_csv_update_config	= "Aktualisiere Konfiguration";

# Extensions by u.sommer
$s_import_file_format_col_spacer = 'CSV Spalten Trennzeichen';
$s_import_skip_blank_lines = 'leere Zeilen auslassen';
$s_import_skip_blank_columns = 'alle Spalten, die einem leeren Eintrag folgen, auslassen';

# Import issues
$s_manage_import_issues_link = 'CSV Datei imporierten';
$s_manage_import_issues = 'CSV Probleme importieren';
$s_import_issues_file = 'Importiere Probleme aus einer CSV Datei';
$s_import_issues_columns = 'Datei Spalten';
$s_import_skip_first_line = 'erste Zeile der Datei auslassen';
$s_import_file_button = 'Importiere Datei';
$s_import_column_number = 'Spalte #%d';
$s_import_result_failure_ct = 'Bei %d Problemen traten Fehler auf';
$s_import_result_import_success_ct = '%d Probleme erfolgreich importiert';
$s_import_result_update_success_ct = '%d Probleme erfolgreich aktualisiert';
$s_import_error_nolines = 'Es muss mindestens eine Zeile zu importieren sein';
$s_import_error_noseparator = 'Jede Zeile muss das Trennzeichen "%s" enthalten';
$s_import_error_manycols = 'Die Datei hat zu viele Spalten';
$s_import_error_col_count = 'Jede Zeile muss die Gleiche Anzahl des Trennzeichens  "%s" enthalten';
$s_import_error_file_not_found = 'Datei konnte nicht gefunden werden';
$s_import_error_col_multiple = 'die gleiche Spalte wurde mehr als einmal definiert';
$s_import_error_bug_not_exist = 'Das Problem %d existiert nicht';
$s_import_error_bug_bad_project = 'Das Problem %d ist nicht im aktuellen Projekt enthalten';
$s_import_error = 'Bei der Verarbeitung des Problems "%s" trat ein Fehler auf';
$s_import_error_custom_field = 'Beim Import des benutzerdefinierten Feldes "%s" zu Problem "%s" trat ein Fehler auf';

# Errors
$MANTIS_ERROR[ERROR_IMPORT_ALL_PROJECT] = 'Es muss ein Projekt bestimmt werden, um Probleme zu importieren';
$MANTIS_ERROR[ERROR_IMPORT_FILE_FORMAT] = 'Das Dateiformat ist nicht korrekt: %s';
$MANTIS_ERROR[ERROR_IMPORT_FILE_ERROR] = 'Die Datei ist fehlerhaft';
?>
strings_german.txt (2,140 bytes)   
Csv_import.111.zip (11,860 bytes)
Csv_import.112.zip (11,629 bytes)
Csv_import.113.tgz (9,716 bytes)
Csv_import.114.tgz (10,275 bytes)
Csv_import.115.tar.gz (9,766 bytes)
Csv_import.120.tar.gz (10,088 bytes)
0001-Utf8-support-and-Real-names.patch (3,220 bytes)   
From c5c80b4b9773ff800fbcf1a3603ce849ec650e1c Mon Sep 17 00:00:00 2001
From: Andreas Back <andreas.back@kapero.fi>
Date: Sun, 19 Jun 2011 15:08:59 +0300
Subject: [PATCH] Utf8 support and Real names

---
 pages/import_issues_inc.php |   39 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/pages/import_issues_inc.php b/pages/import_issues_inc.php
index 8e9640b..db3ef08 100644
--- a/pages/import_issues_inc.php
+++ b/pages/import_issues_inc.php
@@ -8,6 +8,8 @@ if( $g_project_id == ALL_PROJECTS )
 
 # This identify a custom field
 $g_custom_field_identifier = 'custom_';
+#Normally we expect the file to be in Latin1 and the database to be in utf-8
+$g_files_is_ISO8859_1 = true;
 
 # All column names that can be used with this project
 $g_all_fields = array();
@@ -104,9 +106,22 @@ function csv_string_unescape( $p_string ) {
 
 # --------------------
 function read_csv_file( $p_filename ) {
+	global $g_files_is_ISO8859_1;
 	$t_regexp = '/\G((?:[^"\r\n]+|"[^"]*")+)[\r|\n]*/sm';
 
 	$t_file_content = file_get_contents( $p_filename );
+	# Do it exist a UTF-8 byte order mark?
+	$bom = pack("CCC", 0xef, 0xbb, 0xbf);
+	if (0 == strncmp($t_file_content, $bom, 2)) {
+		$t_file_content = substr($t_file_content, 3);
+		$g_files_is_ISO8859_1 = false;
+	}else{
+		$g_files_is_ISO8859_1 = true;
+	}
+		
+	# Need to add a non default module for this so we support both UTF and Latin1
+	#$t_file_content = mb_convert_encoding($t_file_content 'UTF-8');
+	
 	preg_match_all($t_regexp, $t_file_content, $t_file_rows);
 	return $t_file_rows[1];
 }
@@ -137,7 +152,13 @@ function category_get_id_by_name_ne( $p_category_name, $p_project_id ) {
 }
 
 function prepare_output( $t_string , $t_encode_only = false ) {
-	return string_html_specialchars( utf8_encode($t_string) );
+	
+	global $g_files_is_ISO8859_1;
+	
+	if($g_files_is_ISO8859_1 == true){
+		$t_string = utf8_encode($t_string);
+	}	
+	return string_html_specialchars( $t_string );
 }
 
 function get_csv_import_category_id( $t_project_id , $t_category_name ) {
@@ -234,6 +255,10 @@ function get_user_column_value( $p_name, $p_row, $p_default ) {
 		return $p_default;
 	}
 
+	if( ($t_user_id = user_get_id_by_realname($t_username)) !== false ) {
+		return $t_user_id;
+	}
+	
 	if( ($t_user_id = user_get_id_by_name($t_username)) !== false ) {
 		return $t_user_id;
 	}
@@ -253,8 +278,18 @@ function get_user_column_value( $p_name, $p_row, $p_default ) {
 #-----------------------
 function get_column_value( $p_name, $p_row, $p_default = '' ) {
 	global $f_columns;
+	global $g_files_is_ISO8859_1;
+	
 	$t_column = array_isearch( $p_name, $f_columns );
-	return ( ($t_column === false) || (!isset( $p_row[$t_column] )) ) ? $p_default : utf8_encode(trim( $p_row[$t_column] ));
+	$column_val;
+	if(( ($t_column === false) || (!isset( $p_row[$t_column] )) )){	
+		$column_val = $p_default;
+	} elseif ($g_files_is_ISO8859_1 == true){
+		$column_val = utf8_encode(trim( $p_row[$t_column] ));
+	}else{
+		$column_val = trim( $p_row[$t_column] );
+	}
+	return $column_val;
 }
 
 #-----------------------
-- 
1.7.4.msysgit.0

Relationships

has duplicate 0005161 closedgiallu mantisbt Can I load an Excel sheet to populate a new project? 
has duplicate 0003732 closedgrangeway mantisbt Offline bug report 
has duplicate 0012778 closedatrol mantisbt importing issues 
child of 0004181 closed mantisbt Features in Mantis 1.1 release 

Activities

gtomlin

gtomlin

2004-11-19 10:01

reporter   ~0008375

This is something that is an absolute prerequisite for me to migrate to Mantis. There's simply no way I can do so without keeping our existing bug history.

I'm interested to see that this worked for 0.19.a2. I had to change it substantially to work with 0.19.0. Right now I'm playing with it to make it a little more flexible. I'll upload it when I'm done.

Ultimately I will want to add the capability to import old text as bugnotes as well.

jlatour

jlatour

2004-12-01 03:33

reporter   ~0008465

Looks interesting, but it needs some work. It needs to adhere to coding standards and the logic needs to be moved to a core file. Perhaps this feature also needs to be expanded a bit (preview?).

Anyone who wants to work on this?

P.S. Did the author give permission to include this?

gtomlin

gtomlin

2004-12-01 09:17

reporter   ~0008475

Last edited: 2004-12-01 13:12

I have almost completed a modified version of this program that will allow almost any field in an issue to be imported or defaulted or set to a constant value, and will submit it when I am done.

I've sent a note to the author of the original program asking for his permission to submit it.

This is the only issue in the database that I could find that mentions coding standards, so I have to ask: where are the standards documented? Or alternatively, I can submit what I've done and someone can add/change whatever is necessary for conformance.

Edit: completed, waiting for original author's permission.

gtomlin

gtomlin

2004-12-01 16:35

reporter   ~0008487

Received a note from Cas Nuy (the original author):

"Good news, ofcourse you can. Looking forward in checking it out.

Kind regards,
Cas"

At this point, I can either attach the files I have or alter as required to comply with coding standards (which I would need access to). Which would the team prefer?

Matt_wc

Matt_wc

2004-12-01 19:27

reporter   ~0008489

The coding standards are here:

http://www.mantisbt.org/guidelines.php

There is also a link to the more general PHP Standards.

This is great stuff gtomlin - keep it up! =)

jlatour

jlatour

2004-12-02 01:48

reporter   ~0008491

Please look at the coding standards first. Sounds good though!

gtomlin

gtomlin

2004-12-02 08:52

reporter   ~0008494

Note: the link to PHP coding standards on http://www.mantisbt.org/guidelines.php is obsolete. It points to http://utvikler.start.no/code/php_coding_standard.html, which in turn redirects you to http://alltasks.net/code/php_coding_standard.html. This last page says the domain alltasks.net is expired.

gtomlin

gtomlin

2004-12-09 15:08

reporter   ~0008566

Updated version uploaded as mantis_import_issues.zip; I've tested this on 0.19.0 and 0.19.1. Anyone is welcome to use/misuse/abuse or modify it as they see fit. Have fun.

(thanks to Cas Nuy for the original idea!)

jlatour

jlatour

2004-12-09 15:49

reporter   ~0008568

I moved it from 0.20.0 to 0.19.3, but it's too late for 0.19.2.

bclarke

bclarke

2005-01-06 18:44

reporter   ~0008886

Great work on the patch. Had a question: Can this patch can handle importing into existing custom fields? I think that would be helpful if possible, especially when importing from another system.

gtomlin

gtomlin

2005-01-07 09:38

reporter   ~0008889

No it can't as it's presently written. To do this in a generalized fashion would require interrogating the custom field definitions in the database and then constructing the import page on the fly based on what custom fields are defined, and I just didn't have time to do that. For my own needs, if I put more work into this it would be to import external text as bugnotes.

annpatel

annpatel

2005-03-15 19:46

reporter   ~0009552

Thanks for the patch... However, I am having some difficulty getting it to work.
I get a successful import however, none of my data is properly imported... the summary and descriptions are coming up as empty/null when the importing code is calling the create_bug method... in the end, i basically get a lot of blank entries created for project_id = 0 in my bug table. Does any one have any ideas on what I am doing wrong ?

Thank you,
Ann

gtomlin

gtomlin

2005-03-16 11:33

reporter   ~0009554

Try commenting the lines that delete the temporary import table, and use phpmyadmin (or equivalent) to have a look at the data in that table. This should help to narrow down the problem.

annpatel

annpatel

2005-03-16 14:24

reporter   ~0009556

Thanks for the info... Actually, I figured it out. I had previously commented out the summary and description while I was debugging and for got to put them back in... my bad. It works great!

Thanks again,
Ann

Scipion

Scipion

2005-03-31 03:38

reporter   ~0009691

Last edited: 2005-03-31 03:39

I tested gtomlin's contribution (mantis_import_issues.zip) under 0.19.2 it works fine. I have two small issues:
1 - Fixed in Version field is imported in mantis_import table but not migrated to the system
2 - Build field is imported in mantis_import table but not migrated to the system

Results of investigation for item 2:
I identified one potential bug in import_issues.php file (I am not an expert) and needs to be validated:

Set up build

if($f_buildx == IMPORT_FROM_FILE) {

$t_build = $a_buildx[$i] ; (replace $a_buildx[$i] to $a_build[$i])

$t_build = $a_build[$i] ;

} else if ($f_buildx == IMPORT_USE_CONST_VALUE) {
$t_build = $f_const_build;
} else {
$t_build = '' ;
}

gtomlin

gtomlin

2005-05-10 15:51

reporter   ~0010071

Sorry for the delay in getting back to this...bogged down with other work.

Scipion's suggested fix corrected the problem for the "build" field. and the "fixed in version" field problem has been fixed by using bug_set_field() after bug_create(), since bug_create() does not set fixed_in_version.

Before uploading the fixed files, I need some guidance from the team. In 1.0.0a(x), function print_manage_menu() in core/html_api.php tests authority for each menu item before printing a link to it. What authority do you think should be tested for importing issues?

gtomlin

gtomlin

2005-05-11 14:16

reporter   ~0010090

Uploaded new version (mantis_import_issues_v2.zip). Tested on 0.19.0 and 1.0.0a1. Made an "executive decision" that import should require ADMINISTRATOR access.

gtomlin

gtomlin

2005-05-27 13:02

reporter   ~0010264

This issue is marked as a child of 0.20.0, which is obviously never going to be a real release as we're at 1.0.0a[n] now. It's still in feedback status but it's not apparent what that feedback might be. What do we need to do to get this one back on track?

vboctor

vboctor

2005-06-01 11:10

manager   ~0010322

gtomlin, I didn't run the script yet, but I like the idea of a configurable importer.

  • I wonder if this is a feature that is needed as part of the application vs. as part of the administration section (i.e. admin/ folder). Having it as part of the application is nice, but is it needed?

  • You should be able to use user_get_id_by_name() from user_api.php rather than defining your own methods. Maybe this method wasn't implemented in 0.19.x. If that is the case, then you script should use the standard API if the function exists.

  • When constructing the $t_column_list in import_issues.php consider creating an array of columns, then imploding the array into a string with the comma as the separator. This will simplify your code.

  • Consider creating core/import_api.php and move as much functionality to the api.

  • Use standard Mantis headers.

  • Use function( x ) rather than function(x).

  • Use $g_db_table_prefix and $g_db_table_suffix to name the table for the import.

  • Given that you are processing the file sequentially, is it really of use to import the file into a table?

  • Why do you read all issues in memory, then write all issues to the database. Why don't read one issue, then write it, and so on.

  • You can add a menu option to the main menu using $g_main_menu_custom_options, we should probably implement a similar technique to add custom options to the manage menu. Although if your patch gets integrated into Mantis, then we won't need it.

  • You can rename your custom_strings_inc.php to import_custom_strings_inc.php and require the users to include it from their custom_strings_inc.php or create a custom_strings_inc.php to include it from. Same for custom_constants_inc.php. This may simplify the updates for your patch, however, it is not needed if this becomes part of Mantis main distribution.

More to come later. I will need to set it up and do some testing.

fredckp

fredckp

2005-06-03 05:57

reporter   ~0010344

will like to confirm the data will be imported to the current project view?
thanks.

gtomlin

gtomlin

2005-06-03 19:46

reporter   ~0010358

fredckp, issues will be imported into whatever project is the current project when you start the import. If you are not in the desired project, switch before starting the import.

gtomlin

gtomlin

2005-06-03 20:10

reporter   ~0010359

Thanks for the feedback Victor...I'll incorporate the bulk of your suggestions. A few comments:

  • Should it be part of the application? I'd say so, since (a) you need to set up users, projects etc. before it is even reasonable to try importing issues, and (b) it could become necessary to import issues from another source at a later date long after the admin directory has been removed.

  • core/import_api.php - I'll look into it. It's probably not important now but could be later if we start importing other things like users and projects.

  • As far as the points regarding use of a table and order of reading and writing are concerned, these are things that I didn't change from the original contribution that I picked up. As it turns out, though, it proved handy sometimes to have the imported data in a table to look at it with phpMyAdmin after an unsuccessful import.

jschrader

jschrader

2005-06-08 06:21

reporter   ~0010406

There was a discussion about implementing this as an administrator task or as part of the application. I appreciate implementing as part of the application because I will need this feature frequently. We often get Excel Sheets from our customers; it would be nice to import these and this should be done by someone with manager rights.

Just my humble opinion on that feature.

joostbaaij

joostbaaij

2005-07-22 11:05

reporter   ~0010919

There are a couple of issues with this functionality. First of all, it doesn't work on the Safari browser (MAC OSX 10.4). But that might be a Safari thing, it does work with Firefox.

The more serious, showstopper bug though: it turns out that for recent versions of MySQL the LOAD DATA LOCAL INFILE was removed because of an apparent "security issue". After hours of searching I finally found the way to re-enable LOAD DATA LOCAL INFILE again.

Edit the file core/adodb/drivers/adodb-mysql.inc.php.
In it, find its own class definition. Change $clientflags like so:
var $clientFlags = 128;

Now I was finally able to upload the file, but alas, MySQL did not find my uploadfile. So now I'm stuck.

Error message: File 'bugs.txt' not found

vJack

vJack

2005-10-20 15:04

reporter   ~0011518

Last edited: 2005-10-20 15:07

Hi joostbaaij, Were you able to find a solution to the file not being found?
I was getting error: "The used command is not allowed with this MySQL version" (using MySQL 4.0.25-standard / PHP 4.3.11)
I then changed to $clientflags=128 as you suggested and then got the same error you now have: "File 'C:/Import_Columns_2.csv' not found (Errcode: 2)". If you have a solution please let me know. I'm using Mantis 1.0.0rc1 and import_issues_v2. Thanks!

joostbaaij

joostbaaij

2005-10-21 03:16

reporter   ~0011519

The only way it is going to work, is upload the file to the server (via ftp/scp etc). It doesn't matter if you choose client/server the importer always looks on the server. sadly enough.

dingdong

dingdong

2005-10-21 14:59

reporter   ~0011521

joostbaaij, where exactly the file needs to be uploaded on the server? Directory?

vJack

vJack

2005-10-21 16:52

reporter   ~0011522

I have put the file on the server, in the same directory as Mantis, but can't get it to recognize the file. I click 'Start Import' and nothing happens, the page doesn't reload or anything. If I switch the path to a local drive 'C:/..' then it responds with the 'Can't find file error'. If you have an example syntax for a server path that you've found works it would help a lot.

My next step is to manually import the records into the Mantis_Import table the tool created (using PhpMyAdmin), then comment out the LOAD FILE part of the script, and retry running the tool from that point. Any other ideas?

gtomlin

gtomlin

2005-10-24 10:44

reporter   ~0011525

There's not enough info in these recent posts to enable anyone to help.

What is the actual file location? How exactly are you typing it on the import issues page? What platform are you running? What MySQL version? What PHP version? What Mantis version?

For LOAD DATA LOCAL security considerations, see:
http://dev.mysql.com/doc/refman/5.0/en/load-data-local.html
The ability or inability to use LOAD DATA LOCAL is in the installation's hands.

vJack

vJack

2005-10-25 18:12

reporter   ~0011536

Hi gtomlin, thank you for offering to help.

This is my setup:
OS: Windows XP
Browser: IE 6.0 (Tried FireFox 1.0.7 too)
MySQL: 4.0.25-standard
PHP: 4.3.11
Mantis: 1.0.0rc1
Import Tool: mantis_import_issues_v2.zip
File Location: Local PC drive
Actual File Path: 'C:\Import_Columns_2.csv'
Typing in form : 'C:/Import_Columns_2.csv'

Local Client Import Error Message:
Importing from: C:/Import_Columns_2.txt
Importing into project: Mantis Changes
Importing columns: (reporter,summary,description)
File 'C:Import_Columns_2.txt' not found (Errcode: 2)

I have never been able to import a file. Not from my local PC or from the server. When trying to load a file from the server the page stays as is after clicking 'start import'. It doesn't refresh or throw an error. Any help would be great, thank you!

gtomlin

gtomlin

2005-10-26 11:49

reporter   ~0011545

I tested both client and server imports successfully and only after doing so I noticed that you are specifying 'C:/Import_Columns_2.csv' but the import is attempting to access 'C:Import_Columns_2.txt'. It looks to me like your system is doing something strange.

vJack

vJack

2005-10-26 14:56

reporter   ~0011546

Thank you for taking the time to test it. I'll keep digging to see what the problem might be.

gtomlin

gtomlin

2005-11-04 10:42

reporter   ~0011595

Updated version uploaded: mantis_import_issues_v3.zip. Addresses the following items in Victor's note 10322:

  • use user_get_id_by_name() from user_api.php rather than defining a custom method

  • simplified construction of column list.

  • Use standard Mantis headers.

  • Use function( x ) rather than function(x).

  • Use $g_db_table_prefix and $g_db_table_suffix to name the table for the import.

  • Process each issue as it is read from the temporary table rather than constructing arrays.

As I mentioned in my note 10359, it makes sense for the importer to be a part of the distribution, since it may be necessary to run it after the admin directory has been removed. Accordingly, I haven't done anything to the way the custom_constants_inc.php and constant_strings_inc.php files are updated.

BTW, is there a syntax to generate a link to a bugnote (analogous to # and an issue number to generate a link to an issue)?

vboctor

vboctor

2005-12-02 17:25

manager   ~0011684

gtomlin,

I've attached version 4 of the patch which includes the following:

  1. Fixes for some notices that were generated by the code. Please turn notices ON to be able to see all errors in the code.

  2. Used db* rather than mysql*.

  3. Remove dieclean() since it was no longer used after using db*.

  4. A couple of other minor issues (use file compare to make sure my fixes are correct).

I'd recommend the following:

  1. Consider avoiding the use LOAD DATA INFILE since it seems to be disabled by default in MySQL. I think it will be much easier to use, setup, and more portable if you upload the text file, process it via PHP, delete the upload temporary file.

  2. For the options of importing fields, it would be good to have an option for "default (if not exists)". This means that script should import the value in the text file, only if it is valid; otherwise it should use the default specified.

Note: Without changing MySQL settings, I could only get it to import a file from the server that is located in the database directory.

vboctor

vboctor

2005-12-03 06:45

manager   ~0011686

Error generated when importing a server based file on a MySQL 4.1.14-standard installed on Linux:

Database query failed. Error received from database was 0001045: Access denied for user 'username'@'localhost' (using password: YES) for the query: LOAD DATA INFILE "./testissues.txt" REPLACE INTO TABLE mantis_import_issues_table FIELDS TERMINATED BY ";" LINES TERMINATED BY "\r\n" (summary,description);

Importing the file from the browser machine worked fine. Is there a specific location on the server that the file should be placed?

The current situation is:

  • On my Windows box, I only got it working using the server based file.
  • On the Linux hosted environment, I only got it working using the user local file.
ag

ag

2005-12-08 08:19

reporter   ~0011743

I just tested the mantis_import_issues_v4 on Mantis 1.0.0rc3 and the import worked without issue. As a non-programmer I have 2 queries that would really help if anyone had an answer.

  1. Has anyone tried importing data including original bug id numbers? If you have managed this what code changes did you make?

  2. Does anyone have an example of a custom field that they imported using this, what code changes did you need to make for this?

vboctor

vboctor

2005-12-09 17:33

manager   ~0011765

A couple of other comments:

  • When importing a file from a windows client, the \ should not be replaced by /.

  • Although the description field is not marked as mandatory, it is. I have changed the script to use the summary for description, if description is empty.

gtomlin

gtomlin

2005-12-12 10:16

reporter   ~0011779

Victor, when you say that '\' should not be changed to '/' on a Windows client, what platform was MySQL running on? According to the MySQL 5.0 Reference Manual (see http://dev.mysql.com/doc/refman/5.0/en/load-data.html), "Note that Windows pathnames are specified using forward slashes rather than backslashes. If you do use backslashes, you must double them." My tests were done with client and server both on Windows boxes, and my results were:

  • \ - file not found
  • \ - file not found
  • / - OK
ag

ag

2005-12-12 10:38

reporter   ~0011780

I read the / \ comment and I thought I would share my experience.

I used mantis_import_issues_v4 on Mantis 1.0.0rc3 on a WinXP machine running MySQL 4.1.11. Importing a cvs file from c:\ and I found it necessary to change the \ to /.

If someone could advise me how to import custom fields using this I would really appreciate it.
Thanks AG

gtomlin

gtomlin

2005-12-12 11:13

reporter   ~0011781

AG, this is just using bug_create(), which creates an issue without custom fields. To make this importer support custom fields would be a substantial project.

vboctor

vboctor

2005-12-18 06:16

manager   ~0011807

I've attached v5 which includes the following changes:

  1. Uploads the file to the server temporary directory, then imports it from there.
  2. Escapes the strings before using them in constructing SQL queries. This is to avoid SQL injection attacks.

This will probably break the server-side files. Do we really need to support such case?

gtomlin

gtomlin

2005-12-21 10:17

reporter   ~0011825

I had a look at your v5 files, and the approach should be fine. The important thing is that the facility works for all users in all environments. The user just needs to know where the file needs to be located when he/she starts the process.

grangeway

grangeway

2005-12-22 04:37

reporter   ~0011826

Isn't this something that it would be more sensible to use mantisconnect to do?
I'm thinking a 'php client which talks to the webservice' before anyone says anything about c#.

Importing Issues somewhat strikes me as something you'd do from a command line script, rather then a webpage - for example, I did start trying to use a c# client at work, to add issues to mantis based on the output of an xml file.... Personally, I'm thinking this sort of thing is something better done as a contributed script/addon, then as a 'core feature'

In terms of a critical review of issues in v5:

  1. DROP TABLE IF EXISTS is mysql specific, and shouldn't be used.
  2. CREATE TABLE uses VARCHAR(32) etc - this should use ADODB's type's instead.
  3. Creating/dropping tables should be done as part of the installation, not as part of the script.
  4. LOAD DATA INFILE / REPLACE INTO TABLE / FIELDS TERMINATED BY / LINES TERMINATED BY / LOAD DATA LOCAL INFILE is specific to mysql and shouldn't be used.
  5. why is the table even needed in the first place? If someone uploads a comma seperated file - why not open it on the server, and do the parsing there, rather then importing it into a database and retrieving it again?
  6. I think import_issues.php should call helper_begin_long_process();
jblanchon

jblanchon

2005-12-22 05:18

reporter   ~0011827

While you were working on bug corrections, I developped the following features required at my work.

  • Import custom fields
  • Import "status" field
  • Import "resolution" field
  • Import "date submitted" field

Because some fields are set to default by bug_create, function bug_set_field is used to import extra fields (status, resolution, date submitted). A consequence is that the bug history is updated each time such a field is imported. Custom fields API, specially custom_field_set_value, is used to import custom fields values.

Unfortunatly, this is based on V3 version and all modifications till V5 have to be merged. Does anyone want to perform this merge? I will attach this version as Mantis_Import_Issue_v3.1.

jblanchon

jblanchon

2005-12-23 05:17

reporter   ~0011838

Sorry, the archive V3.1 is just a copy of V3 :-(
Use V3.1_effective instead.

Why a reporter can't delete its own attached file in this page?

vboctor

vboctor

2006-01-05 07:18

manager   ~0011871

Thanks jblanchon for your contribution. I uploaded v6 which includes the following:

  • I merged your changes (v3.1).
  • Did some code cleanup.
  • Some changes towards Mantis standards.
  • Did some fixes relating to the importing of status, resolution, fixed in release.
  • I didn't do any testing relating to custom fields.
atomoid

atomoid

2006-01-18 23:27

reporter   ~0011959

Last edited: 2006-02-10 14:25

I'm trying to import the sample "testissues.txt" file as-is and I get:
APPLICATION ERROR #11
A necessary field '' was empty. Please recheck your inputs.

Somebody (apparently) fixed the script so that you no longer have to modify the path on Windows systems (as i remember in older versions having to switch the slashes). Therefore, if you follow the now-misleading directions and painstakingly change all the backslashes, you will experience app error #11.

...So I adjusted: "custom_strings_inc.php" at line 18: "$s_import_instructions_2 = "2. Specify the input file (Windows users change all \ to / in file name) and its characteristics.";

... replacing this line 18 with:
"$s_import_instructions_2 = "2. Specify the input file and its characteristics (Some Windows users may need to change all '\' to '/' in pathname).";

I submit only the "custom_strings_inc.php" file since somebody should verify that the syntax above is not problematic on non-Windows systems (i'm not certain about the '\' and '/' part). Then it could be folded into the main distribution.

mgfeller

mgfeller

2006-01-30 16:16

reporter   ~0012043

Last edited: 2006-01-30 16:18

First, thanks for the great work!

I have applied a few changes to import_issues.php and hope that they are usefull. The reason was that I could not import data, receiving application error 11. Basically, in the section that creates the bug entries from the temporary table, columns are now referenced by key instead of by index number, and the loop has been changed to a for loop. The PHP Version used in my environment is 4.4.2, and Mantis is 0.19.3.

I don't know if I should supply a new version or if you, gtomlin, will incorporate my changes. Also, I'm not sure whether my changes will work in other versions of PHP etc. My changes are based on mantis_import_issues_v6.zip.

Please let me know how I can best submit my suggestions.

gtomlin

gtomlin

2006-01-30 17:50

reporter   ~0012044

mgfeller, Victor and others have changed this script substantially since I last touched it (which was _v3). I don't presently have any time to work on this, and I wouldn't want everyone else waiting for me because the last note mentioned my user name!

MPA

MPA

2006-03-02 10:54

reporter   ~0012268

Using version 6!

When I try to import a file I get this error message:
APPLICATION ERROR 11
A necessary field '' was empty. Please recheck your inputs.

Does it has to be txt file? I used a csv file.

I put my file on the server in the root of my Mantis directory and still I'm getting this error message.

What am I doing wrong??

mgfeller

mgfeller

2006-03-03 12:51

reporter   ~0012280

MPA, try mantis_import_issues_v6.1.zip which incorporates my changes as well as custom_strings_inc.zip submitted by atomoid.

michael

wade_albright

wade_albright

2006-03-10 14:00

reporter   ~0012322

Last edited: 2006-03-10 14:04

I am using 6.1 with mantis 1.0.1. Not sure if that is supposed to be supported or not, but I get the:

APPLICATION ERROR 11
A necessary field '' was empty. Please recheck your inputs.

No matter what I try when using the import page. I tried importing only the 2 required fields, and setting all the rest to either default or expclitly setting, same error as above.

Is there a way to turn on some sort of logging besides "a required field was empty?" Maybe print out the name of the field that was empty? Or maybe that error message is just a red herring.

vboctor

vboctor

2006-03-10 17:09

manager   ~0012323

wade_albright, do you have a custom field that is required when submitting a new issue?

wade_albright

wade_albright

2006-03-10 17:26

reporter   ~0012324

vboctor, no, not that i know of. i'm just using 1.0.1 out of the box.

MPA

MPA

2006-03-14 04:45

reporter   ~0012332

Last edited: 2011-11-01 11:48

Using Mantis version 1.0.1 with import v6.1 gives me the following error;

With the import file on the server in the Mantis root folder;
APPLICATION ERROR 0000401
Database query failed. Error received from database was 0001045: Access denied for user: 'parlitco@localhost' (Using password: YES) for the query: LOAD DATA INFILE "/tmp/phpNnxdiN" REPLACE INTO TABLE mantis_import_issues_table FIELDS TERMINATED BY ";" LINES TERMINATED BY "\r\n" (reporter,priority,severity,reproducibility,status,resolution,category,view_state,summary,description,
custom_field_2,custom_field_5,custom_field_9,custom_field_3,custom_field_4,custom_field_8);

It seams that I don't have autorisation for de DB. This seems not correct. I'm sure that I'm using the correct name and password. But what about localhost? MySQL is running on the server at my provider. Maybe this has got something to do with it?

And maybe someone can attach a demo import file which is working correctly, so I can check/test this out?

EDIT: dregad 2011-11-01 break long lines to avoid horizontal scrolling

mgfeller

mgfeller

2006-03-14 06:29

reporter   ~0012335

I'm afraid I have tested mantis_import_issues_v6.1.zip only with Mantis 0.19.3. I hope to use Mantis 1.0.1. soon... and then maybe extend the error messages, if at all possible. The app err 11 usually meant (for me) that the parsing didn't work at all.

Are field delimiter and end of line marker ok? Does your data make it into the temporary table (result of LOAD DATA INFILE ...)?

MPA

MPA

2006-03-16 09:55

reporter   ~0012353

Are field delimiter and end of line marker ok? Does your data make it into the temporary table (result of LOAD DATA INFILE ...)?

Yes, It seems that all other variables are ok. And no, the temporary table is not filled.

I'm getting very close!
I'm not sure if my import file is correct. Maybe someone can confirm this. In my import file i'm using the id's for the reporter, status, severity, view status, etc.
Like this; 10;20;10;30;10;etc.

Is it possible that someone can sent me a import example file, where every column is used, including which columns i have to set on 'import', 'default' or 'Set all to'?
I would appriciate that very much.

arnov2

arnov2

2006-04-27 09:20

reporter   ~0012738

I tried the 6.1 version on a system where the mysql server runs on a windows machine, and the apache/php runs on a FreeBSD machine. I placed the import file on the windows machine, and checked the 'server based' checkbox.
This did not work. The gpc_get_file() function assumes that the file can be approached from the php/apache server, which was not the case. After changing file input to an ordinary text input, the script ran succesfully.

Unchecking the 'server based' check box gave a lot of problems with MySQL rights. I could not figure out how to handle this.

rudy

rudy

2006-05-17 05:18

reporter   ~0012855

I'm trying to use the 6.1 version on a windows system with easyphp installed. Im having the following error message:

Error 401: database query failed.

I'm using a very simple file to test the import feature, i tried to manually launch the query "load data infile..." in the temporary table, it worked perfectly. Any idea where the problem comes from?

By the way i would need to do the import manually for some reasons, could anyone tell me how to build the queries i will need to do it?

ewyssa

ewyssa

2006-07-19 10:46

reporter   ~0013116

I use the "issue import v6.1" with Mantis V1.0.3. On the mysql server the "local infile" option is enabled. Still I get an error:

Database query failed. Error received from database was #1148: The used command is not allowed with this MySQL version for the query: LOAD DATA LOCAL INFILE "/tmp/php20HwUP" REPLACE INTO TABLE mantis_import_issues_table FIELDS TERMINATED BY ";" LINES TERMINATED BY "\r\n" (reporter,summary,description);

How can I avoid this and import an issue?

ewyssa

ewyssa

2006-07-20 04:23

reporter   ~0013123

Last edited: 2006-07-20 04:28

Sorry I don't saw before but 0004220:0010919 solved the problem.

mbernigaud

mbernigaud

2006-08-04 03:51

reporter   ~0013188

Last edited: 2006-08-04 04:04

The custom field date type where imported as String.
I added few lines to convert the String date of the CSV to a real date type in the database:

August 2006 - mBernigaud : don't set empty date -->

if ( $t_custom_field_value != '') {

August 2006 - mBernigaud : Convert string date to its internal value if ( $t_def['type'] == CUSTOM_FIELD_TYPE_DATE ) {

$t_custom_field_value = strtotime( $t_custom_field_value ) ;
}
if( !custom_field_set_value( $t_id, $t_bug_id, $t_custom_field_value ) ) {
echo '

' . lang_get( 'import_custom_field_failure' ) . $t_def['name'] . ' :
' . $t_summary . '

';
$t_error_count++;
$t_error = true;
}
}
The v6.1.1 includes this fix

carp3tshark

carp3tshark

2006-09-12 09:41

reporter   ~0013370

I'm currently (9/12/2006), unable to download the files. They download to a 0k file. Not sure if this has to do with the recent domain change. Also, I'm hoping there are some instructions within the file about the installation and use. If not I plan to write some and will post them if desired by others.

atomoid

atomoid

2006-09-12 13:19

reporter   ~0013372

carp3tshark ,

This probably ocurred when Mantis switched their nameserver or upgraded to 1.1a1
A similar thing happened to me as noted in this forum post: http://forums.mantisbugtracker.com/viewtopic.php?t=307
I already sent a note to Victor.

jbatop

jbatop

2006-09-21 16:11

reporter   ~0013426

Hello

Where are attached files ?

atomoid

atomoid

2006-09-21 18:40

reporter   ~0013428

Last edited: 2006-09-21 18:44

Since this hasnt been fixed yet, i uploaded the most recent version i had,
which of course, isnt the most recent version.

I titled it "mantis_import_issues_v6.1--reuploaded.zip" since it wouldnt let me upload a duplicate name, anyway there it is...

in a pinch you can roll in the 6.1.1 fix noted in the post above: (0013188) mbernigaud

hmackiernan

hmackiernan

2006-11-15 18:21

reporter   ~0013725

Hello:
I couldn't find this documented anywhere
What is the expected value for Status in an import file?
I've tried both the literal string
New
and the numeric constant
10
and both seem to get munged to zero (0) on import.

ave

ave

2006-12-18 01:18

reporter   ~0013839

I found a problem in the 'mantis_import_issues_v6.1--reuploaded.zip'.
'View Status' is set to public even if I set 'Set all to' as private.

It was easy to fix.
The line 511 of import_issue.php

} else if ( $f_buildx == IMPORT_USE_CONST_VALUE ) {

should be

} else if ( $f_view_statex == IMPORT_USE_CONST_VALUE ) {

RyanR

RyanR

2006-12-19 15:44

reporter   ~0013847

Does anyone have a 1.1.0a2 patch for this feature? Also, will it eventually be easy to use the same php extension to export issues to a file as well?

midtoad

midtoad

2006-12-29 22:01

reporter   ~0013876

Last edited: 2011-11-01 11:50

I've tried a multiplicity of different combinations trying to get the csv importer to work. It appears that it doesn't respect the order of the fields that I put in my csv file, based on what I can see from the error message. Here's my input file (containing 2 lines) which imports data for every single field in the 'import issues' page:

"reporter";"handler";"priority";"severity";"reproducibility";"status";"resolution";"category";"date_submitted";
"os";"os_version";"platform";"version";"fixed_in_version";"build";"view_status";"summary";"description";
"reproduce";"info";"custom_field_2";"custom_field_1";"custom_field_3"
"svermeul";"svermeul";low;"minor";"always";"closed";"open";"go";"1998-07-16";
"win";"xp";"win";"none";"tip";"0";"private";"Default numeric format seetting";"Description: test";
"how to reproduce";"more info";"date closed";"bug";"19838"

and here are the columns the importer says it's importing:
(reporter,handler,priority,severity,reproducibility,status,resolution,category,date_submitted,
os,os_build,platform,version,fixed_in_version,build,view_state,summary,description,
reproduce,info,custom_field_2,custom_field_3,custom_field_1)

but notice the error message:
error importing custom field PR_number : "Default numeric format seetting"

it's complaining about the last field in the input file, but the data that it says it received for that field is actually from a field in the middle of the line.

Would anyone have a sample record that actually works? Please post it here for everyone to see or drop me a line at stewart 'at' midwinter 'dot' ca.

thanks so much!

EDIT: dregad 2011-11-01 break long lines to avoid horizontal scrolling

midtoad

midtoad

2006-12-29 22:02

reporter   ~0013877

BTW, I'm running Mantis 1.06 and mySQL 4.1.20.

ave

ave

2007-01-01 10:39

reporter   ~0013886

midtoad, what happens if you remove double quotation marks for each fields?

midtoad

midtoad

2007-01-16 14:58

reporter   ~0013928

removing the double quotations from all fields except those with commas in the text has no impact on the importer. It still appears to process the fields in the wrong order.

This is a blocker issue for me. I can't use Mantis if I'm unable to import my existing issues.

ave

ave

2007-03-26 12:54

reporter   ~0014248

I have attached 'mantis_import_issues_v7.zip' which allows you to import 'target version' introduced in 1.1.0.
It also contains fixes reported in 0004220:0013188 and 0004220:0013839.

Notes:

  • The 'target version' is displayed only in mantis 1.1.0a1 or later.
  • The 'category' field is required in 1.1.0 (0007801).

Tested on:

  • Mac OS X 10.4.9 / MySQL 5.0.27 (utf-8) / Mantis 1.0.6
  • Mac OS X 10.4.9 / MySQL 5.0.27 (utf-8) / Mantis 1.1.0 (latest CVS)
  • Debian 3.1 / MySQL 5.0.27 (utf-8) / Mantis 1.1.0 (latest CVS)

--
midtoad,
Sorry, I missed the point in my last comment.
You cannot specify the order of fields. See the usage section of the 'readme.txt'.

akocel

akocel

2007-05-21 10:19

reporter   ~0014575

I use v6.1 import function and have fixed in it a bug relative to custom fields of type date : their values need to be converted to php internally format by
strtotime function.

See import_issue.php uploaded 2007-05-21 10:15 (sorry I forgot to suffix it
with v6.1)

deboutv

deboutv

2007-06-05 04:01

reporter   ~0014674

Hi,

I have written a plugin to import/export data from/to Mantis. Import supports only XML format at this time but other formats will be supported soon.
http://deboutv.free.fr/mantis/plugin.php?plugin=importexport

sveyret

sveyret

2008-07-04 09:23

reporter   ~0018302

I added a new importer inspired by the one posted by ave. This one allow to import CSV files, where columns are in any order you want. It also can update issues, instead of creating them if you have a bug id column. And finally, it does not use the MySQL load data functionality (which was not working in my firm), but only Mantis PHP functions, and therefore is compatible with any supported database.
See csv_import-1.0.tgz

Hope this can help.

sveyret

sveyret

2008-07-16 06:58

reporter   ~0018581

There is an error in the script I uploaded in import_issues.php at line 117. This line should be:
$t_bug_exists = array_search( 'id', $f_columns ) !== false;

Buga

Buga

2008-07-21 05:43

reporter   ~0018623

I just tested the Import but the import of custom fields dont work at all
I am using mantis 1.1.1.

All other data is imported correctly.
Any idea whats wrong?

Buga

Buga

2008-07-21 10:08

reporter   ~0018627

I found the problem...
there is a little bug in the importissue.php
at line 246 the custom fiels are retrieved but without a custom

Thats why they cant be found later

For my needs I simply added a line

Look if this field is set

$t_def = custom_field_get_definition( $t_id );
$tdef['name']="custom".$t_def['name'];

vboctor

vboctor

2008-08-04 09:42

manager   ~0019016

We should consider re-developing this patch as a plugin for Mantis 1.2.x. I will look into it when I get a chance unless someone else beats me to it.

osterwaldi

osterwaldi

2008-09-23 08:53

reporter   ~0019430

Last edited: 2008-09-23 09:17

Is it possible to transform this tool that a note can be imported. Should have a note for this ID exist, a new note added.
Would it be possible to the text separator ',' or ';' return to the options presented?

Greeting
osterwaldi

uso

uso

2008-10-06 10:38

reporter   ~0019499

Last edited: 2008-10-06 11:30

I wanted to write something about the new file csv_import-1.0.1.zip,
but there occured an error in database_api.php as i tryed to send my text.

That is why the note I wrote was posted so often.
I'm sorry about this, i have deleted all previous notes of mine with same content.

uso

uso

uso

2008-10-06 11:06

reporter   ~0019500

Last edited: 2008-10-06 11:34

I have done some little work on the CSV Import plugin.
It is now able to work as plugin for Mantis version > 1.2.0.
Also I've implemented some features, like automatically adding handlers,
if they are listed in the CSV-File and do not exist in the database.

I made changes to CSV Import 1.0 only for my company,
intentionally it was not planned to release the changes.
But now I saw it helped me a lot, so I released it.

I hope it will help somebody, too. But do not treat me if it does not. ;-)

(I'm sorry to the developers, my coding style is not what it should be...)

uso

prabhurangan

prabhurangan

2009-02-26 04:24

reporter   ~0020946

Dear Members,

I am so confused in choosing the right version of mantis.

I need import option in mantis 1.1.6, where the other plugins like myViewIssues,Hierarchy plugins are to be supported by this.....

Please do let me know, how to use and which one to use with mantis 1.1.6 to have the option to import in to CSV or XML format.

Is there anyway by means of customization, we could use the import/export plugin version 0.0.4 to use with mantis1.1.6

Regards,
Prabhu.

thungp

thungp

2009-03-05 16:45

reporter   ~0021009

I'm also looking for an import excel feature and wondering if 1.1.6 has it.
I'd also like to suggest for consideration that an import feature keep this in mind.

  1. Keep track of what was imported and check for duplication so we don't contaminate the core Mantis issues table with duplicate entries.

  2. Take into consideration concepts like updating existing mantis issues if the imported data is an update to an existing issue based on some correlation field like say some unique ID from another system that Mantis is also tracking.

  3. have an ability to determine what the default behavior is of certain fields such as status or category and whether or not an import where there is already an existin mantis issue on whether to update the field or let the existing field take precedence. One thing which can complicate matters is to possible code Mantis to determine if it's fields have the concept of Null, where the person entering in the issue did not know the value of the field versus it was a default value. Should an update update a null value? I think yes. Should an update update a defaulted value? It depends. If the defaulted value has a value like Unknown I think it should update that value because it is equivalent to Null, however, if a field has a value of Resolved for example, I may not want this third party import updating what I may have painstankenly figured out and changed manually.

  4. This brings up the point of possibly having an intermediary view of potentially imported values where a test import could occur and a comparison view opens up showing a diff on the merge and allow a human to determine which field (either the existing mantis field or the imported field) should take precedence or the option of changing it all together.

cas

cas

2009-03-16 06:38

reporter   ~0021051

Needed to import issues into 1.2 and adjusted this plugin to fit my needs.
Now no more manual action, also added the due-date column to be imported.
Version 1.1.0 at your service!

prabhurangan

prabhurangan

2009-03-16 06:45

reporter   ~0021052

@cas

Cas will this CSV import work with mantis 1.2.0a3, please let me know. Already i have XML import contributed by you. Now please let me know how to use this CSV import with the XML import.

Regards,
Prabhu

cas

cas

2009-03-16 13:32

reporter   ~0021060

The XML is not by me.
This one works with 1.2.0a3, no problems

prabhurangan

prabhurangan

2009-03-16 23:43

reporter   ~0021066

Oh yes, Reminder is by you......

prabhurangan

prabhurangan

2009-03-16 23:48

reporter   ~0021067

Dear All,

I have an issue with XML import; It is working fine in WINDOWS machine, but it throws some error in LINUX machine; Any one faced this issue.
I would like to know where the imported files are kept by mantis, while importing issues. Also Export feature is also not working in LINUX.

Or it would be a file permission in LINUX.

Error:
Error i faced is, The file could not be found at http://localhost/mantis/plugin.php=ImportExport/Import-action

Regards,
Prabhu.

prabhurangan

prabhurangan

2009-03-17 01:46

reporter   ~0021068

Dear All,

I am facing this issue while trying to import issues using CSV Import:

Fatal error: Call to undefined function explode_enum_arr() in C:\Documents and Settings\prabhu_rangan\workspace\mylo\plugins\Csv_import\pages\import_issues.php on line 76

Please anyone let me know what is wrong with this.

Also which are the required fields to import CSV issues, to create new issues; like the attribute 'ID' should be specified '0'

Regards,
Prabhu

cas

cas

2009-03-17 03:22

reporter   ~0021069

Add the following code @ the end of import_issues_inc.php (before the closing tag):

--------------------

# Given one num:value pair it will return both in an array
# num will be first (element 0) value second (element 1)
function explode_enum_arr( $p_enum_elem ) {
    return explode( ':', $p_enum_elem );
} 

Have updated my source also.

prabhurangan

prabhurangan

2009-03-20 05:29

reporter   ~0021118

@cas

I am facing this isssue, do i have to add a function same as to 'explode_enum_arr()'

Fatal error: Call to undefined function explode_enum_string() in C:\Documents and Settings\prabhu_rangan\workspace\mylo\plugins\Csv_import\pages\import_issues.php on line 73

prabhurangan

prabhurangan

2009-03-20 05:35

reporter   ~0021119

@cas

Sorry cas, its my mistake.

No issue

prabhurangan

prabhurangan

2009-03-20 05:47

reporter   ~0021120

@cas

I have added a custom_field 'Deadline' and 'Est.' hours to my view issues and while importing issue to CSV, i need to import values to these two fields also, how shall i perform it.

In the '$g_all_fields' array i have mentioned my default columns for import, but after importing i could not see the values imported for these two fields.

Can you please share your ideas

cas

cas

2009-03-20 06:26

reporter   ~0021122

Custom fields will show up in the list of available fiedls automatically.
Please do not change the code for this but ensure that the custom fields are connected to the project in which you are importinh.

nobswolf

nobswolf

2009-04-07 02:28

reporter   ~0021410

it should bring up some error messages if type or content of columns do not match

in some cases like invalid values for category you do not get HTML at all

in that respect also two feature requests:

  • create the entries in the column of the CSV as new possible values for that column

  • create a column of the CSV as new custom column

apart from that: a real good tool; it makes mantis a lot more usefull than it already is, great work, thanks

BTW: does the CSV import has an own web page? maybe this plugin is enough of a project of its own so it should its own tracker

nobswolf

nobswolf

2009-04-07 04:25

reporter   ~0021413

feature request:

match automagically columns with same name

advantage: you could prepare the import in the application that generates the CSV without matching each column manually during the import

even moving issues from one mantis system to another would be very easy that way

cas

cas

2009-04-07 05:07

reporter   ~0021414

Although I started this tool in the past, GTOMLIN took over. I then converted the latest code into a plugin sinci I was excercising plugin development and used 1.2.
For me this tool is good enough since one would only use it every now and then (at least that is my impression).
But if you (or someone else) would like to make this a continuous project, feel free to do so. The code is attached.

monotek

monotek

2009-04-08 10:59

reporter   ~0021439

Is this patch scheduled to find its way into the next release (1.2.x)?

Is it possible to import files via linux shell?

I dont want to login as admin to import csv files but would upload it via ftp to mantis temp directory. This file should get imported by a cronjob/shellscribt.

cas

cas

2009-04-09 16:03

reporter   ~0021457

It is not a patch but a plugin and it is available for 1.2
There is a xml import/export which perhaps can be scheduled.
This plugin does not support it.

prabhurangan

prabhurangan

2009-04-13 04:35

reporter   ~0021484

@cas

In this csv import plugin, while importing issues a default category named 'csv_imported' is created and if the category field is given empty or if it is missed out, the default category created is assigned. Instead it would be nice to have a validation if the category field is left empty while importing issues.

As for now it looks odd to have a category named 'csv_imported' in the category table as it does not mean anything.

Please let me know your suggestions in this.

uso

uso

2009-04-14 05:32

reporter   ~0021507

@prabhurangan

at the time i've (re)written the plugin for version 1.2.x it was impossible to
import bugs without a category.
the project i have had consisted of a very large csv so i was to lazy to look through all the listed bugs in this csv and set the categroy where left blank.

also it was too much to collect it by the time of the import and then give an error to the importer, because then he/she would have had to fix this by hand.
the goal was to import the issues and the user(s) which was/were assigned to the bug(s) has/have to collect und correct the the empty fields by him-/herself.

so i've decided to write a fallback to make it possible to import issues without category and collect them under "csv_imported" so the users have a place were they can look for their bugs and assign them correct.

best regards
uso

prabhurangan

prabhurangan

2009-04-14 05:58

reporter   ~0021509

@uso

Ya i could understand. As 'Category' is a mandatory field in 1.2.x while creating issues.

prabhurangan

prabhurangan

2009-04-22 16:52

reporter   ~0021628

@cas

I have a big issue, in DueDate Reminder notification: It is working fine in windows; however if set it as a cron job in Liniux machine, it is not working. Also i am not receiving emails. When i checked it, we will be giving a syntax like "/1440 * lynx --dump http://mantis.homepage.com/plugin.php?page=Reminder/bug_reminder_mail.php" and in this "lynx" is a text based browser and I installed it in linux machine, even now i am not receiving any emails. If I execute the cron job, it shows me the "login_page.php" It shows the text content in that page. But the notifications is not coming.

Please let me know your thoughts....

cas

cas

2009-04-23 03:37

reporter   ~0021632

You should really post under the correct issue. This is not about the reminder plugin.
The problem looks like an authorisation issue. I have no linux config available so cannot check.

jojow

jojow

2009-05-06 07:48

reporter   ~0021782

great job for this plugin!!!
I've uploaded a german translation for the strings.

mantistestor

mantistestor

2009-05-07 08:28

reporter   ~0021789

Great plugin! But it doesnt work for me. I have a problem with importing a csv. Probably i used a wrong tabledefinition. does it exist a example-csv?
thx,

uso

uso

2009-05-07 08:54

reporter   ~0021790

Last edited: 2009-05-07 08:55

configure your mantis as you want (custom fields, etc.),
adding some test case users, bogus bugs and so on...

if you've done this, use native mantis EXport capabilities to
export your db to a csv.
(dont forget to make the CSV columns fit to your needs.
=> http://<your_mantis_sleeps_here>/adm_config_report.php
or even better
=> http://<your_mantis_eats_here>/manage_config_columns_page.php)

then open the csv and see ... .

best regards

decep

decep

2009-06-03 16:39

reporter   ~0022041

Uploaded csv_import-1.0a_mantis1.1.tgz. Tested against Mantis 1.1.7

Changes:

  • For some reason all dates were being converted to epoch when they need to be mysql formatted dates (removed all "strtotime" calls).
  • Comment #0018627
  • Typo on line 83 of import_issues.php

Changes were made to csv_import-1.0.tgz which I believe is the last version compatible with Mantis 1.1.

decep

decep

2009-06-09 23:01

reporter   ~0022068

I made a mistake in "csv_import-1.0a_mantis1.1.tgz" so do not download. If somebody can delete, please do so.

"csv_import-1.0b_mantis1.1.tgz" is the replacement.

squarebox

squarebox

2009-11-09 21:14

reporter   ~0023629

using csv_import-1.0b_mantis1.1.tgz

the column detection is case-sensitive, i.e. if you have "id" instead of "ID" no columns will be detected

vidalpj

vidalpj

2010-04-12 10:21

reporter   ~0025105

sorry.. but could someone provide an example csv? thanks..

Fyb3roptik

Fyb3roptik

2010-04-20 10:58

reporter   ~0025163

I get Issue 0 not found when I try to import. I am using Mantis 1.2.0 on a fresh install.

robertog

robertog

2010-05-03 04:09

reporter   ~0025368

Hi all, i'm experiencing the same problem posted by Fyb3roptik : csv file correctlyt read and values displayed, however, starting rows importation in to the database, data importing stops immediately displaying following error message :
"Message header = APPLICATION ERROR #1100"
"Message body = Issue 0 not found"
i'm trying to find out why;
my environment is :
Mantis version : 1.2.0
Schema version : 182
Importing patch version : thus belonging to uploaded folder : csv_import-1.0b_mantis1.1
Thanks in advance !
Roberto

decep

decep

2010-05-03 12:58

reporter   ~0025372

It is rather confusing, but csv_import-1.0b_mantis1.1 is only for Mantis 1.1.x. You will have to read through all of the comments to determine which versions are compatible with 1.2.x.

Andi3938

Andi3938

2010-05-03 17:25

reporter   ~0025382

So which version is compatible with mantisbt 1.2.0 and which with 1.2.1?

I'd like to import about 200 issues from a excel spread sheet. I tried the xml import with no success. Even a reimport (xml export -> xml import) does not work (bug 0010794) and does not support custom fields (bug 0011876).

This plugin is my last hope. Or are there other ways (not manually) to import a bulk of issues?

andy778

andy778

2010-05-18 15:14

reporter   ~0025534

To get csv import to work under 1.2.x, what is the recommended way forward?

  • Port this to a plugin e.g plugins/CsvImportExport
  • Should one extend plugins/XmlImportExport for more formats similar to the import/export plugin found from http://deboutv.free.fr/mantis/
  • ?
cas

cas

2010-05-18 15:59

reporter   ~0025535

csv_import110.zip is for mantis 1.2.x

junkmyfunk

junkmyfunk

2010-05-20 12:11

reporter   ~0025571

Installed csv_import110.zip as plugin in fresh install on Mantis 1.2.0, schema 183 and I'm also getting the error "APPLICATION ERROR #1100 Issue 0 not found" whenever I try to import.

My csv file is uploaded, the headers are automatically recognised and the drop-downs set to the corresponding columns but clicking import throws that error.

Anyone got any ideas what causes this?

cas

cas

2010-05-21 03:49

reporter   ~0025572

Found that I had version 1.11 on the shelf.
Please verify, if it gives problems, please attaced sample csv file to this issue so I can investigate.

junkmyfunk

junkmyfunk

2010-05-21 12:13

reporter   ~0025580

@cas

Found a couple of issues with this: The "APPLICATION ERROR #1100 Issue 0 not found" is being triggered on line 261 of import_issues.php - when $t_default->description is used, the BugData class attempts to get the description from the DB but it doesn't have an id, since you're just using it to store default values. Setting a default description around line 220 avoids this issue.

However, after doing this I'm getting Fatal error: Call to undefined function bug_create() on line 316

I can also see a call to bug_update() which doesn't exist either.

cas

cas

2010-05-21 13:37

reporter   ~0025582

send me the csv (or attach here) you use and I will fix the issues

cas

cas

2010-05-27 08:17

reporter   ~0025616

attached version 1.1.2 which handles reported issues.
I also found that in your importfile some mandatory fields were not filled. That should be avoided since the import program will stop in those case.
I have adjusted the importfile and saved again as csv (this time with semicolon as eperator). Next step clearly is to connect the columns to the proper fields.
Finally it imported nicely.

kimkb

kimkb

2010-06-08 05:02

reporter   ~0025755

Last edited: 2010-06-08 05:04

Thanks for your cvs_import.
Everything is good but exisiting issues cannot be updated.
Issues always are created.
The cvs_import checks id columns well.
Could you help me?
(Mantis: Mantis 1.1.0rc1, csv_import-1.0b_mantis1.1.tgz)
cvs file:
ID,Category,Status,Reproducibility,Severity,Summary,Description,Additional Information,Due Date,View Status
114,SW,acknowledged,always,major,DB1 SRS Driver I/F ? ?td>,DB1 SRS Chap 4.3 HW I/F Driver I/F ? ???.,,,public

kimkb

kimkb

2010-06-08 20:20

reporter   ~0025770

I found the solution to update the existing issues.
The CSV file must have all columns and order.
If you entered the exisiting issue id, the issue is updated.
ex)
Reporter (ID),Summary,Description,Steps To Reproduce,Additional Information,Category,Priority,Severity,Reproducibility,Date Submitted,Last Update,Assigned To (ID),Status,Resolution,OS,OS (Build),Platform,Version,Projection,ETA,Fixed in Version,Target Version,Build,View Status,ID
,DB1 SRS Driver I/F ? ?td>,DB1 SRS Chap 4.3 HW I/F Driver I/F ? ???.,,,SW,normal,minor,always,2010-06-08 15:19,2010-06-09 09:13,,acknowledged,open,,,,,none,none,,,,public,114

kdcinfo

kdcinfo

2010-07-20 19:42

reporter   ~0026106

The solution to updating existing issues does not work for me. I export a CSV to one file, make a minor change to the Excel file, export a second CSV file. I import file 1 no problem. Import file 2 and they're all new issues. No changes to the 'id' numbers at all.

I'm trying to mess around too see what's what, and running into stuff like the "$t_bug_exists" variable coming back as 0 (my 'id' column is column 0 in the array) which evaluates to false when simply doing a boolean check on the varialbe (it as it does 4 times in the import_issues.php file). So I replaced the "true" condition to be ($t_bug_exists >= 0). No go :(

kdcinfo

kdcinfo

2010-07-20 19:43

reporter   ~0026107

Unless anyone else has done it, I'm also trying to create a Mapping Save feature. I've created a separate table with 4 columns (map_id, map_prj, map_cvs, map_mantis) to store the field mappings (saved per project). I'm doing this by trying to add a few new methods in the bug_api.php -> BugData Class.

I'm sure there's a better place to store these by extending the class in another file, but don't know enough about classes. The new methods I'm creating are; create_map_def(), update_map_def(), and get_map_def(). Hoping that on the mapping page, I can default in any previously selected fields from the dropdowns so that subsequent runs won't require selecting them all again.

Any input appreciated :)

kdcinfo

kdcinfo

2010-07-21 17:03

reporter   ~0026115

Last edited: 2010-07-21 18:05

Just as an FYI to anyone who didn't already know ('cause it took me awhile to figure it out), this plugin, or at least the latest version of this plugin (112), is not compatible with Mantis 1.0.8, which is the version we're using in our office.

I'm not sure which version of Mantis = which version of this plugin, but I do know that much. Just wanted to clear that up for anyone new coming into this.


UPDATE:

Just came across (or noticed rather):
$this->requires = array('MantisCore' => '1.2.0',);

cas

cas

2010-07-22 02:58

reporter   ~0026117

The plugin system is only available as of version 1.2 so that also indicates the compatibility of the plugin.
For older versions, you need to use an earlier version (ie the last vesion before it becamne a plugin). Have a go at mantis_import_issues_v7

dregad

dregad

2010-09-14 13:40

developer   ~0026713

I tried this plug-in today, and after a few trials and errors, managed to successfully import a bunch of issues.

Many thanks to all those who contributed to this !

If I may make a suggestion, it would be nice if the imported records, would be marked as such in the Issue History, i.e. the Change Column showing the name of the file as in the example below, or something similar.

Date Modified Username Field Change
2010-09-14 19:07 Administrator New Issue Imported from xyz.csv

dregad

dregad

2010-09-14 14:01

developer   ~0026714

Last edited: 2010-09-16 09:23

I just noticed that when importing issues into a sub-project which is inheriting Categories from its parent, the plug-in seems unable to match the value in the CSV's column with the ID in mantis_category_table.

In Mantis, assume the following categories exist for sub-project:
[ParentProject] Parent Category
Child Category

In CSV, I tried the following values in the Category column, without success on import (i.e. always ending up with category = csv_imported)
a) Parent Category
b) [ParentProject] Parent Category
c) <ID of [ParentProject] Parent Category>

I would expect the plug-in to be able to find a match with a).

Note: I have not tested with global categories as I do not use them currently

This is on Mantis 1.2.1 by the way.

m.vanhamme

m.vanhamme

2010-10-06 07:07

reporter   ~0026972

I tried to import a csv file. Mapped the fields. At the end of the import i get the following error:

Invalid e-mail address

But there is no email address mapped.

cas

cas

2010-10-07 03:50

reporter   ~0026989

Do you have by chance a mandatory customfield defined that would hold an email address?

lionheart33806

lionheart33806

2010-11-04 11:32

reporter   ~0027249

Last edited: 2010-11-04 11:33

Hi,
I don't understand the regexp of read_csv_row function.
Why does it care about double quotes?

If I have a string like : abcd"fzefz"feizjfz
PREG stops matching after the letter d (and ignore everything after it).

Shouldn't be like that :
/\G(?:\A|_SEPARATOR)((?!")[^_SEPARATOR]+|(?:"[^"]"))/sm

instead of
/\G(?:\A|_SEPARATOR_)([^"SEPARATOR]+|(?:"[^"]"))/sm

?

sveyret

sveyret

2010-11-04 12:36

reporter   ~0027251

I added a new version of the plugin (1.1.3). I made two minor changes on it:

  • Made the strings and errors "private" as they should be in a plugin.
  • Added a french version of the strings.

Enjoy!

sveyret

sveyret

2010-11-05 04:57

reporter   ~0027260

@jojow
Entschuldigung, I hadn't seen your file for german translation. I added it to the plugin and so uploaded version 1.1.4.
If you have time, please have a look at it to check that I didn't make any mistake. There also are a few new strings which are not translated (I kept english version for those as my german is not good enough) !

lionheart33806

lionheart33806

2010-11-10 05:36

reporter   ~0027323

1.1.5 version is my contribution.

Changelog :

  • Code closer of mantis coding conventions
  • "all projects" categories reusable
  • Can import "submitted date" with DD/MM/YYYY format
  • Checkbox for alternative import because of double quotes
  • Added helper_begin_long_process() for very long imports
andy778

andy778

2010-11-10 08:50

reporter   ~0027327

Wouldn't it be good to have this src in git or svn somewhere?
e.g mantisforge

in latest 1.1.5 the version number was 1.1.3 in Csv_import.php
$this->version = '1.1.3';

lionheart33806

lionheart33806

2010-11-10 09:47

reporter   ~0027330

Sorry for the mistake ...

Great idea !
But who should create it ?

lionheart33806

lionheart33806

2010-11-16 06:01

reporter   ~0027376

1.2.0 version is my new contribution.

Changelog :

  • import_issues_page.php splitted to become import_issues_page_init.php and import_issues_page_col_set.php
  • Can create unknown categories
  • Little JS to use tab as separator
TomR

TomR

2010-11-16 18:09

reporter   ~0027388

Last edited: 2010-11-16 18:14

open_basedir restriction in effect. File() is not within the allowed path(s)

I am getting an open_basedir restriction. However can not figure out which path should be defined.

I define the $HOME of mantis installation, the upload path for the project, the general upload path from the config_inc.php.

But none of these are OK. Which path should be added?

cas

cas

2010-11-17 03:01

reporter   ~0027390

Last edited: 2010-11-17 03:03

Do you have this statement in your config_inc.php:
$g_path = 'http://path_to_your_mantis_installation/';

TomR

TomR

2010-11-17 04:01

reporter   ~0027391

Hi Cas,

not initially. ( Using 1.2.3 ). But even when I put the absolute path in, same error occurs.

But l other default stuff of Mantis regarding uploading files is working. To which (sub)directory the functions tempnam() and move_uploaded_file() referring?

SYSTEM WARNING: tempnam() [function.tempnam]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/proguide/:/home/proguide/domains/proguideweb.nl/public_html/abs-pad/upload:/var/www/ctstestdocs:/var/www/testtrackdocs:/var/www/testwiki:/var/www/devtrackdocs:/var/www/devwiki:/var/www/html/jpgraph-3.0.6:/usr/local/lib/php/:/tmp:/usr/share/fonts/)

SYSTEM WARNING: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/proguide/:/home/proguide/domains/proguideweb.nl/public_html/abs-pad/upload:/var/www/ctstestdocs:/var/www/testtrackdocs:/var/www/testwiki:/var/www/devtrackdocs:/var/www/devwiki:/var/www/html/jpgraph-3.0.6:/usr/local/lib/php/:/tmp:/usr/share/fonts/)

TomR

TomR

2010-11-17 04:47

reporter   ~0027395

Problem is in line 112 from
import_issues_page_col_set.php

Changed it into
$t_file_name = tempnam( '.', 'tmp' );

Function does not seem to like an empty directory a first parameter. Can someone perhaps comment on that?

TomR

TomR

2010-11-17 04:54

reporter   ~0027396

How can you import in such a way that the due date is empty?

Default the due date is becoming the dat of today with time 00:00, this effectivly means that the item is after import overdue.

Importing with column due date set to 1, will import it as due date set to 0, which lead to displaying it as 01/01/1970.

The due dat should have the value 1, not 0 ( zero ) to display it as empty. But how can I import the value '1'?

TomR

TomR

2010-11-17 05:09

reporter   ~0027397

OK, about the due date, also figured that out.

I changed the default.

$t_default->due_date = date('Y-m-d');

    $t_default->due_date = 1;

Perhaps it would be nice to make this configurable. Otherise make the default = 1, in my opinion this is more logical than assign a due date which is already overdue.

lionheart33806

lionheart33806

2010-11-17 05:24

reporter   ~0027398

I created a github repository here : https://github.com/lionheart33806/Csv-import-4-MantisBT

jmonin

jmonin

2010-11-17 11:13

reporter   ~0027405

Thanks for that, lionheart33806!
Shall we start using the issues section instead of this bug, which seems quite inappropriate and hardly usable?

dregad

dregad

2010-11-17 12:55

developer   ~0027406

Sounds like a great idea ! This page is totally unmanageable.

lionheart33806

lionheart33806

2010-11-18 03:25

reporter   ~0027409

Last edited: 2010-11-18 03:55

I'm agree to use issues section too.

lionheart33806

lionheart33806

2010-11-24 05:40

reporter   ~0027467

I've just release v1.3.0b on github (if you don't use git, just use "Downloads" button).
Please test it.

TomR

TomR

2010-11-24 08:00

reporter   ~0027473

Lionheart,

could you please comment on my remarks:

0004220:0027395, 0004220:0027396 and 0004220:0027397

lionheart33806

lionheart33806

2010-11-24 08:49

reporter   ~0027475

Last edited: 2010-11-24 08:50

Ok, try this source : https://github.com/lionheart33806/Csv-import-4-MantisBT/commit/515e2a299f2a2f55a07b6617e35fd798f3b075c0 (via "Downloads")

Please next time use "Issues" section of github

atrol

atrol

2011-01-25 04:33

developer   ~0028067

lionheart33806, are you aware that you can have an own project for this plugin at this instance of MantisBT tracker?
Have a look at the project selection box, where user cas is the manager for the four plugin's

lionheart33806

lionheart33806

2011-01-25 04:52

reporter   ~0028069

Sorry my english is bad, i don't understand you ...
Are you saying that I shouldn't create a githit repo ?

atrol

atrol

2011-01-25 05:00

developer   ~0028071

I think the repo is Ok, but a better place for this would be http://git.mantisforge.org

I was talking about issue tracking for the plugin.
This could be handled with an own project at www.mantisbt.org/bugs

Have a look at the project selection list, where you will find that there are projects for four plugins at the momement.

lionheart33806

lionheart33806

2011-01-25 05:23

reporter   ~0028073

I get it now, thanks !
I was looking for this before creating in github but I didn't found it ...

I'll look it when I'll have more time !

cor3huis

cor3huis

2011-02-05 08:19

reporter   ~0028168

THANK for moving you code to http://git.mantisforge.org !

Just discovered your plug-in, need to try it a little more however found one glitch

The strings with "Csv" should be "csv" , mind the capital "C"

$s_plugin_Csv_import_title = 'Mantis CSV Importer';
$s_plugin_Csv_import_description = 'Import CSV files as Mantis issues';

When I've added them to custom_strings_inc.php it worked.

$s_plugin_csv_import_title = 'Mantis CSV Importer';
$s_plugin_csv_import_description = 'Import CSV files as Mantis issues';

andy778

andy778

2011-02-18 05:24

reporter   ~0028255

Where under http://git.mantisforge.org have you added this plugin, I tried looking for any plugin with cvs or import there but could not find any.

andy778

andy778

2011-03-17 13:42

reporter   ~0028433

We use this plugin to export/import issues beween ms project and I need to fix a couple of things from the version found 0004220:0027475

-When exporting CVS the files comes in UTF-8 but import expect e.g Latin1
-Export takes Real Name but import expect username

So the question is these fixed alreday if yes in wich repos as I seams not be be able to find it under http://git.mantisforge.org and if no where should I commit the changes if I fix these?

AboeBakr

AboeBakr

2011-03-18 06:16

reporter   ~0028440

Nice plugin!
Would like to make some suggestions though:

  • when selecting multiple times 'ignore_column' the script failes due to the check for unique columns
  • first checking if the required fields are filled prevents importing half the list (e.g. 'description')
cor3huis

cor3huis

2011-03-29 07:07

reporter   ~0028500

Get the latest version via Git https://github.com/lionheart33806/Csv-import-4-MantisBT

Fork it, change the defects, and ask the maintainer, to do a Pull request to get all fixes into the mater original branch.

You could then delete your fork

Georges_

Georges_

2011-06-21 02:47

reporter   ~0029044

I was not able to use this plugin. In the readme, the installation part says
"Installation instructions are the same as installing a plugin."

I suggest to describe the full procedure installation in the readme because it's not easy to find the procedure on the net (essentially found instructions for old mantis versions with pluginmanager that is not compatible with new mantis any more).

thank you.

sveyret

sveyret

2011-07-13 04:27

reporter   ~0029156

@lionheart:
Would you please host the plug-in to the now official plug-in place for Mantis which is:
http://github.com/mantisbt-plugins/
Please contact John Reese (who has just created this organization) on the developer mailing list if you need help on this.
A specific project for this plug-in should also be created in this Mantis as it is the case for some other plug-ins.
I think that once done, this issue, which is getting longer and longer with all those comments, will have to be closed.

andy778

andy778

2011-08-11 11:58

reporter   ~0029465

Is the repos https://github.com/lionheart33806/Csv-import-4-MantisBT alive any more? Created a little patch for the mantis Csv plugin that also can take real names and not only user names and if the file contains a UTF-8 BOM characters it will expect the file to in utf-8 instead of Latin-1

I sent this patch file to lionheart33806 19.6.2011 but it seems to have gone out in space. However I have attached the patch here 0001-Utf8-support-and-Real-names.patch

Rustan

Rustan

2011-08-31 23:35

reporter   ~0029611

Hi Guys, I've found this plugin useful and I'm about to use it on our production environment. I have tested it on my local and it seems fine. However, it seems that it doesn't send emails for the uploaded entries. Do you think if it is possible that it can be tweaked to send emails for all the entries imported by this plugin? Just the same as submitting a single entry.

Rustan

Rustan

2011-09-02 01:59

reporter   ~0029620

Sending emails for each of the bugs imported through this plugin.

Guys, I was able to fix what I need and I just want to share this piece of idea. Actually , this is based on the bug_report.php included in the mantis core package. If you want to have an automated email sent for each of the new bugs imported by this plugin, just add these lines from bug_report.php to import_issue.php included in this plugin just before the # Result comment:

helper_call_custom_function( 'issue_create_notify', array( $t_bug_id ) );
email_new_bug( $t_bug_id );

Result

if($t_error) {
$t_failure_count++;
}
else {
$t_success_count++;
}

Hope it helps!

lionheart33806

lionheart33806

2011-09-13 09:37

reporter   ~0029697

I'm (a little) back !

Sorry, I didn't have time to work on the plugin.

Let me a bit of time to see your notes.

lionheart33806

lionheart33806

2011-09-14 03:18

reporter   ~0029703

@Rustan : Interesting idea ! I added it in github "issues".

@andy778 : I can't find something (mail or github) about your patch :-/

@sveyret & Georges_ : It's on the way.

@cor3huis : Is your plugin folder named "csv_import" ? Try "Csv_import".

@AboeBakr : Can you be more "clear" about the 2nd problem ?

andy778

andy778

2011-09-14 09:58

reporter   ~0029709

@lionheart33806 the patch is also here as an attachment 0001-Utf8-support-and-Real-names.patch

Rustan

Rustan

2011-09-15 23:28

reporter   ~0029738

Guys, I encountered issue when trying to test in on our dev environment:

SYSTEM WARNING: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/tmp/D9R8wM) is not within the allowed path(s): /data/otherlocation

Would you know where can I tweak this location? I think it points by default to /tmp location and it is not where we upload temp files.

Your help is very much appreciated.

lionheart33806

lionheart33806

2011-09-16 03:18

reporter   ~0029740

Last edited: 2011-09-16 03:19

Look at sys_get_temp_dir() (import_issues_inc.php, import_issues_page_col_set.php and http://php.net/manual/en/function.sys-get-temp-dir.php)

Rustan

Rustan

2011-09-16 05:17

reporter   ~0029744

@lionheart33806 - it does not get inside the if condition:

import_issues_inc.php:

if ( !function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if( $temp = getenv('TMP') ) {
return $temp;
}
if( $temp = getenv('TEMP') ) {
return $temp;
}
if( $temp = getenv('TMPDIR') ) {
return $temp;
}
$temp = tempnam(FILE,'');
echo "\$temp: ".$temp."
";
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
}
echo "\$temp: ".$temp."
";
echo realpath(sys_get_temp_dir());

The output of this one is:

$temp:
/tmp

Can i override the system temp directory to point to /data/otherlocation?

AboeBakr

AboeBakr

2011-09-16 06:26

reporter   ~0029746

@lionheart33806

regarding the second problem,
some fields, for example 'description' are required.
When the csv has a row, where the column mapped to 'description' is empty,
the import will fail.

the problem is: it inserts all the entries up to the row with the missing description.

as it is now, you have too look up at which point in the csv it goes amiss,
then remove all the rows above this point, save the csv and then restart the import.

the line at which it is failing is not reported as well, making this even more inconvenient.

If the csv would be scanned for these missing fields, you could either import all entries or none. And preferably report to the user at which row/column there is a problem.

dregad

dregad

2011-09-16 11:01

developer   ~0029747

@Rustan
sys_get_temp_dir() as the name indicates, returns the system temp dir (which is not the same as the upload temp dir). I assume that you expect the plugin to use the location specified in upload_tmp_dir, but that won't work (see https://bugs.php.net/bug.php?id=54710).

To work around the problem, assuming you're using apache, you could try to

  • modify your apache envvars file, to add: export TMPDIR=/data/otherlocation
  • modify your open_basedir to allow your system temp dir (there could be security implications there though), e.g. /data/otherlocation:/tmp

Maybe the plugin should be improved to check that the path returned by sys_get_temp_dir() is checked for accessibility prior to further processing.

lionheart33806

lionheart33806

2011-09-19 09:23

reporter   ~0029804

Last edited: 2011-09-19 09:24

The repository moved to https://github.com/mantisbt-plugins/csv-import

@Rustan : please try latest tarball

Rustan

Rustan

2011-09-19 21:13

reporter   ~0029806

@dregad - thanks for the info, actually, i understand that it uses the system-defined temp dir but, as i have said, we have a defined temp location to write on such as /data/otherlocation. your suggestion can be done on the server side. can i change the location, say define the /data/otherlocation because i know that where i have write privilege?

@lionheart33806 - thanks, ill try that.

lionheart33806

lionheart33806

2011-09-20 02:26

reporter   ~0029808

My changes only try to prevent the warning message.

Rustan

Rustan

2011-10-18 23:24

reporter   ~0029997

@lionheart33806 - thanks, it works. now, when i implemented this into our production, im having problem when i clicked the upload file button, here is the error:

APPLICATION ERROR #11
A necessary field "" was empty. Please recheck your inputs.

Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

sveyret

sveyret

2011-10-20 03:21

reporter   ~0030001

The CsvImport project is now created in Mantis BT (see the project drop down at top right of this window). If you have any more problems concerning this plug-in, please open a new issue in the corresponding project.
Can someone close this issue to prevent people from adding information?
Thank you.

PeterThoeny

PeterThoeny

2011-11-01 01:09

reporter   ~0030136

Last edited: 2011-11-01 01:15

I am trying to import a csv file using the [ Import CSV file ] plugin link in the manage screen. I installed Csv_import.120.tar.gz

I get the same error like m.vanhamme above: "Invalid e-mail address". There is no e-mail address in the csv file, in fact there is not even an @ sign. The source is actually a converted xml file from a mantisbt export, only with default fields. Fields as defined in the first line of the csv: ID, Reporter, Assigned To, Priority, Severity, Reproducibility, Product Version, Category, Date Submitted, OS, OS Version, Platform, View Status, Updated, Summary, Status, Resolution, Fixed in Version. (no space after comma in csv, added here for clarity)

Suspecting that the converter is choking on certain content I tried to convert only the first 10 records of a 480 record csv file. Same result.

Then I tried to import records 10-20. Now I get this: "APPLICATION ERROR #11. A necessary field "Description" was empty. Please recheck your inputs." There is no Description field?

I also tried to import the xml using the [ Import issues ] plugin link. This fails showing an empty screen with URL: https://example.com/mantisbt/plugin.php?page=XmlImportExport/import_action - an no data imported.

Any help in how to import data from another mantisbt is greatly appreciated, thank you.

dregad

dregad

2011-11-01 12:30

developer   ~0030140

Celebrity alert ! We've got the famous creator of TWiki in the house :-)

Hi Peter,

I can't really help you with your question, hopefully lionheart33806 who maintains the plugin will have an answer for you. Nevertheless, I would suggest to get the latest source for the plug-in from Github [1], instead of the tarballs attached to this issue.

Damien

[1] https://github.com/mantisbt-plugins/csv-import

PeterThoeny

PeterThoeny

2011-11-01 14:44

reporter   ~0030141

Thank you Damien. I installed the latest Mantis CSV Importer 1.3.0b from github.

Now I get this error:

APPLICATION WARNING #300: String "plugin_Csv_import_result_nothing_success_ct" not found.

When I omit the ID field I get again this error:

APPLICATION ERROR 0001200: Invalid e-mail address.

Hmm...

PeterThoeny

PeterThoeny

2011-11-04 13:32

reporter   ~0030177

Apparently the Description field is mandatory, so I added it. However, import still gave me the e-mail error.

I did a brute force import: Wrote a script that uses curl to push the data record by record via http posts. Problem solved (with much more effort than it should be).

Thanks for your help anyway!

VeMag

VeMag

2011-11-18 10:33

reporter   ~0030249

about 0004220:0030141 , if you try to import handler or reporter who doesn't exist in your mantisbt, then it will try to create it...

but function user_create() in user_api.php do "email_ensure_valid(email)" even if email is '', that's an "Invalid e-mail address."

so, don't import handler or reporter or write in plugins\csv_import\pages\import_issues_inc.php :
line 253:
if( user_create( $t_username , $t_username, 'nomail@for.me' ) ) {

Not good for security : password = username...

belfar

belfar

2011-11-23 18:39

reporter   ~0030322

teste

Rustan

Rustan

2011-11-27 21:58

reporter   ~0030346

VeMag is correct. If you are trying to assign an entry to a user with invalid email address, it would give you an error of invalid email address. to fix this, you can disable the checking of valid email addresses of users being assigned to an entry.

andropoliss

andropoliss

2011-11-29 13:56

reporter   ~0030361

hI, FUNNY PROBLEM!

keimpe@planet.nl

keimpe@planet.nl

2012-05-14 07:18

reporter   ~0031829

When I import a CSV file everything goes well.
It generates new issues and all information for the standard mantis fields are filled in.

Except for the custom fields.
It reconizes the customfields, I can sellect them in the import tool.
But it just does not import the information for the custom fields.

Is there something I forgot?
Do I have to add somewere the custom fields I want to import?

I've latest verion 1.3.0b, mantis 1.2.8.

vboctor

vboctor

2014-06-09 21:57

manager   ~0040775

Resolving this issue in favor of the version of the extension hosted in github and has been getting the recent fixes.
https://github.com/mantisbt-plugins/csv-import/