Anonymous Login
2016-05-27 18:02 EDT

View Issue Details Jump to Notes ] Wiki ]
IDProjectCategoryView StatusLast Update
0004220Plugin - CsvImport[All Projects] Generalpublic2015-07-29 10:32
Assigned Tovboctor 
Summary0004220: * Import new Issues from file
DescriptionI found some php file extensions for the possibility to import new issues from an external file. These feature is developed by, but works for me and me 0.19.a2 installation.
Is someone interested in this extension?
Attached Files
  • zip file icon (5,283 bytes) 2004-07-29 12:53
  • zip file icon (10,585 bytes) 2004-12-09 15:05
  • zip file icon (11,430 bytes) 2005-05-11 14:14
  • zip file icon (12,033 bytes) 2005-11-04 10:29
  • zip file icon (12,489 bytes) 2005-12-02 17:15
  • zip file icon (12,599 bytes) 2005-12-18 06:13
  • zip file icon (12,784 bytes) 2005-12-23 05:14
  • zip file icon (13,690 bytes) 2006-01-05 07:14
  • zip file icon (986 bytes) 2006-02-10 14:27
  • zip file icon (14,255 bytes) 2006-03-03 12:48
  • zip file icon (15,008 bytes) 2006-08-04 03:59
  • zip file icon (14,255 bytes) 2006-09-21 18:38
  • zip file icon (15,059 bytes) 2007-03-26 12:51
  • ? file icon import_issues.php (22,471 bytes) 2007-05-21 10:15 -
    	# Mantis - a php based bugtracking system
    	# Copyright (C) 2000 - 2002  Kenzaburo Ito -
    	# Copyright (C) 2002 - 2004  Mantis Team   -
    	# 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)
    	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__ );
    	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' ) ) );
    	# 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';
    		$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
    /*	# @@@ 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_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 {
    				# 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 = true;
    			if ( !$t_error ) {
    				echo '<p>' . lang_get( 'import_success' ) . $t_bug_id . ": " . $t_summary . '</p>';
    		else {
    			echo '<p>' . lang_get( 'import_failure' ) . $t_summary . '</p>';
    	#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;
    ? file icon import_issues.php (22,471 bytes) 2007-05-21 10:15 +
  • tgz file icon csv_import-1.0.tgz (7,213 bytes) 2008-07-04 09:20
  • zip file icon (14,981 bytes) 2008-10-06 10:28
  • zip file icon (11,786 bytes) 2009-03-16 06:36
  • txt file icon strings_german.txt (2,140 bytes) 2009-05-06 07:46 -
    # 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';
    txt file icon strings_german.txt (2,140 bytes) 2009-05-06 07:46 +
  • tgz file icon csv_import-1.0a_mantis1.1.tgz (7,276 bytes) 2009-06-03 16:33
  • tgz file icon csv_import-1.0b_mantis1.1.tgz (7,266 bytes) 2009-06-09 23:00
  • zip file icon (11,860 bytes) 2010-05-21 03:48
  • zip file icon (11,629 bytes) 2010-05-27 08:18
  • tgz file icon Csv_import.113.tgz (9,716 bytes) 2010-11-04 12:34
  • tgz file icon Csv_import.114.tgz (10,275 bytes) 2010-11-05 04:52
  • gz file icon Csv_import.115.tar.gz (9,766 bytes) 2010-11-10 05:30
  • gz file icon Csv_import.120.tar.gz (10,088 bytes) 2010-11-16 06:00
  • patch file icon 0001-Utf8-support-and-Real-names.patch (3,220 bytes) 2011-08-11 11:56 -
    From c5c80b4b9773ff800fbcf1a3603ce849ec650e1c Mon Sep 17 00:00:00 2001
    From: Andreas Back <>
    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;
    patch file icon 0001-Utf8-support-and-Real-names.patch (3,220 bytes) 2011-08-11 11:56 +

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



gtomlin (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

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

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

Kind regards,

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 (reporter)

The coding standards are here: [^]

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

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


jlatour (reporter)

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


gtomlin (reporter)

Note: the link to PHP coding standards on [^] is obsolete. It points to, [^] which in turn redirects you to [^] This last page says the domain is expired.


gtomlin (reporter)

Updated version uploaded as; 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 (reporter)

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


bclarke (reporter)

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 (reporter)

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 (reporter)

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,


gtomlin (reporter)

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 (reporter)

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,


Scipion (reporter)

Last edited: 2005-03-31 03:39

I tested gtomlin's contribution ( 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 (reporter)

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 (reporter)

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


gtomlin (reporter)

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 (developer)

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 (reporter)

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


gtomlin (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

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/
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 (reporter)

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 (reporter)

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 (reporter)

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


vJack (reporter)

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 (reporter)

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: [^]
The ability or inability to use LOAD DATA LOCAL is in the installation's hands.


vJack (reporter)

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:
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 (reporter)

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 (reporter)

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


gtomlin (reporter)

Updated version uploaded: 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 (developer)


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 die_clean() 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 (developer)

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 (reporter)

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 (developer)

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 (reporter)

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 [^]), "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 (reporter)

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 (reporter)

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 (developer)

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 (reporter)

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 (reporter)

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.
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 (reporter)

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 (reporter)

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 (developer)

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 (reporter)

Last edited: 2006-02-10 14:25

I'm trying to import the sample "testissues.txt" file as-is and I get:
    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 (reporter)

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

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



gtomlin (reporter)

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 (reporter)

Using version 6!

When I try to import a file I get this error message:
    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 (reporter)

MPA, try which incorporates my changes as well as submitted by atomoid.



wade_albright (reporter)

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:

    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 (developer)

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


wade_albright (reporter)

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


MPA (reporter)

Last edited: 2011-11-01 11:48

View 2 revisions

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;
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,
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 (reporter)

I'm afraid I have tested 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 (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

Last edited: 2006-07-20 04:28

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



mbernigaud (reporter)

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 = true;
The v6.1.1 includes this fix



carp3tshark (reporter)

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 (reporter)

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: [^]
I already sent a note to Victor.


jbatop (reporter)


Where are attached files ?


atomoid (reporter)

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 "" 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 (reporter)

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
and the numeric constant
and both seem to get munged to zero (0) on import.


ave (reporter)

I found a problem in the ''.
'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 (reporter)

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 (reporter)

Last edited: 2011-11-01 11:50

View 2 revisions

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:

"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:

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 (reporter)

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


ave (reporter)

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


midtoad (reporter)

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 (reporter)

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

- 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)

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 (reporter)

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 (reporter)


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. [^]


sveyret (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

I found the problem...
there is a little bug in the import_issue.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 );


vboctor (developer)

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 (reporter)

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?




uso (reporter)

Last edited: 2008-10-06 11:30

I wanted to write something about the new file,
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 (reporter)

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...)




prabhurangan (reporter)

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



thungp (reporter)

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 (reporter)

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 (reporter)


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.



cas (reporter)

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


prabhurangan (reporter)

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


prabhurangan (reporter)

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 i faced is, The file could not be found at http://localhost/mantis/plugin.php=ImportExport/Import-action [^]



prabhurangan (reporter)

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'



cas (reporter)

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 (reporter)


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 (reporter)


Sorry cas, its my mistake.

No issue


prabhurangan (reporter)


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 (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

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 (reporter)


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 (reporter)


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


prabhurangan (reporter)


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


prabhurangan (reporter)


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" [^] 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 (reporter)

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 (reporter)

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


mantistestor (reporter)

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?


uso (reporter)

Last edited: 2009-05-07 08:55

View 2 revisions

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 (reporter)

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

 * 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 (reporter)

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 (reporter)

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 (reporter)

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


Fyb3roptik (reporter)

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


robertog (reporter)

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 !


decep (reporter)

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 (reporter)

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 (reporter)

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 [^]
- ?


cas (reporter) is for mantis 1.2.x


junkmyfunk (reporter)

Installed 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 (reporter)

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 (reporter)


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 (reporter)

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


cas (reporter)

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 (reporter)

Last edited: 2010-06-08 05:04

View 2 revisions

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 (reporter)

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.
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 (reporter)

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 (reporter)

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 (reporter)

Last edited: 2010-07-21 18:05

View 2 revisions

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.


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



cas (reporter)

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 (developer)

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 (developer)

Last edited: 2010-09-16 09:23

View 3 revisions

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 (reporter)

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 (reporter)

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


lionheart33806 (reporter)

Last edited: 2010-11-04 11:33

View 2 revisions

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 :

instead of




sveyret (reporter)

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.



sveyret (reporter)

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 (reporter)

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 (reporter)

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 (reporter)

Sorry for the mistake ...

Great idea !
But who should create it ?


lionheart33806 (reporter)

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 (reporter)

Last edited: 2010-11-16 18:14

View 3 revisions

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 (reporter)

Last edited: 2010-11-17 03:03

View 2 revisions

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



TomR (reporter)

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/

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/


TomR (reporter)

Problem is in line 112 from

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 (reporter)

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 (reporter)

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 (reporter)

I created a github repository here : [^]


jmonin (reporter)

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


dregad (developer)

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


lionheart33806 (reporter)

Last edited: 2010-11-18 03:55

View 2 revisions

I'm agree to use issues section too.



lionheart33806 (reporter)

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


TomR (reporter)


could you please comment on my remarks:

0004220:0027395, 0004220:0027396 and 0004220:0027397


lionheart33806 (reporter)

Last edited: 2010-11-24 08:50

View 2 revisions

Ok, try this source : [^] (via "Downloads")

Please next time use "Issues" section of github



atrol (developer)

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 (reporter)

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


atrol (developer)

I think the repo is Ok, but a better place for this would be [^]

I was talking about issue tracking for the plugin.
This could be handled with an own project at

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


lionheart33806 (reporter)

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 (reporter)

THANK for moving you code to [^] !

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 (reporter)

Where under [^] have you added this plugin, I tried looking for any plugin with cvs or import there but could not find any.


andy778 (reporter)

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 [^] and if no where should I commit the changes if I fix these?


AboeBakr (reporter)

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 (reporter)

Get the latest version via Git [^]

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_ (reporter)

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 (reporter)

Would you please host the plug-in to the now official plug-in place for Mantis which is: [^]
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 (reporter)

Is the repos [^] 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 (reporter)

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 (reporter)

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) {
else {

Hope it helps!


lionheart33806 (reporter)

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 (reporter)

@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 (reporter)

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


Rustan (reporter)

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 (reporter)

Last edited: 2011-09-16 03:19

View 2 revisions

Look at sys_get_temp_dir() (import_issues_inc.php, import_issues_page_col_set.php and [^])



Rustan (reporter)

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


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)) {
            return dirname($temp);
        return null;
echo "\$temp: ".$temp."
echo realpath(sys_get_temp_dir());

The output of this one is:


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


AboeBakr (reporter)


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 (developer)

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 [^]).

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 (reporter)

Last edited: 2011-09-19 09:24

View 2 revisions

The repository moved to [^]

@Rustan : please try latest tarball



Rustan (reporter)

@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 (reporter)

My changes only try to prevent the warning message.


Rustan (reporter)

@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:

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 (reporter)

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 (reporter)

Last edited: 2011-11-01 01:15

View 4 revisions

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: [^] - an no data imported.

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



dregad (developer)

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.


[1] [^]


PeterThoeny (reporter)

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.



PeterThoeny (reporter)

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 (reporter)

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, '' ) ) {

Not good for security : password = username...


belfar (reporter)



Rustan (reporter)

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 (reporter)


~0031829 (reporter)

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 (developer)

Resolving this issue in favor of the version of the extension hosted in github and has been getting the recent fixes. [^]

-Issue History
Date Modified Username Field Change
+Issue History