BUG: CSVExport of a custom column (inherited MantisColumn)

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
NCDemonic
Posts: 2
Joined: 01 Feb 2011, 19:04

BUG: CSVExport of a custom column (inherited MantisColumn)

Post by NCDemonic »

Hello,
currently I am doing have cutomizations by developing plugins for Mantis. During that work the following problem occured:

I have a custom mantis column created according to many plugins that I found on git.mantisforge.org

Code: Select all

class EstimationSumColumn extends MantisColumn
{
	public $title = "Estimation Sum";
	public $column = "custom_estimation_sum";
	public function display( $p_bug, $p_columns_target )
	{
		/* ... */		
	}
}
In the main plugin file I hooked it:

Code: Select all

function hooks( )
{
    /* ... */
    EVENT_FILTER_COLUMNS' => 'event_filter_columns',
    /* ... */
}
And also programmed the hook

Code: Select all

function event_filter_columns()
{
    require_once( 'EstimationSumColumn.class.php' );
    return array(
          'EstimationSumColumn',
                    );
}
Now I can add the column by the use of the ManageColumn page to "view issues" and to "csv export" but clicking on the Export CSV link results in a csv file with the following error:
Fatal error: Call to undefined function csv_format_timetracking_estimation_sum() in csv_export.php on line 116
Therefore I defined the following function:

Code: Select all

function csv_format_estimation_sum( $p_description ) {
	return csv_escape_string( $p_description );
}
After that I no longer get the error message, but the CSV export contains no values for the custom column. Both, the view issues pages as the Print Reports page show the data of the custom column.

So I investigated the core file csv_export.php. The following section shows the part where the FATAL error came from:

Code: Select all

095:       # export the rows
096:	foreach ( $t_rows as $t_row ) {
097:		$t_first_column = true;
098:
099:		foreach ( $t_columns as $t_column ) {
100:			if ( !$t_first_column ) {
101:				echo $t_sep;
102:			} else {
103:				$t_first_column = false;
104:			}
105:			
106:			$t_custom_field = column_get_custom_field_name( $t_column );
107:			if ( $t_custom_field !== null ) {
108:				ob_start();
109:				$t_column_value_function = 'print_column_value';
110:				helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row, COLUMNS_TARGET_CSV_PAGE ) );
111:				$t_value = ob_get_clean();
112:
113:				echo csv_escape_string($t_value);
114:			} else {
115:				$t_function = 'csv_format_' . $t_column;
116:				echo $t_function( $t_row->$t_column );
117:			}
118:		}
119:
120:		echo $t_nl;
121:	}
After adding debug outputs I found out that during the csv export my custom column gets exported by the else part on line 114 but the $t_row->$t_column contains no data, what would explain why there is no data in the exported CSV file. My assumptions are:

1. I missed something so that the core gets the data in to the $t_row->$t_column and can export it.
But I found nothing in plugins I search on git.mantisforge that would help me. Even worse: All plugins that inherit a custom column as I did have the same problem, that the CSV and Excel export does not work...

or

2.The Mantis Core has a bug. If this is true, then I will further investigate and post an according message into the bugtracker of Mantis and probably also a solution. But before I further investigate I wanted to ask the Forum members, whether I simply missed something that I should have done to get it work...

Any help or comments are welcome :wink:
mhonmon23
Posts: 76
Joined: 22 Sep 2010, 10:43

Re: BUG: CSVExport of a custom column (inherited MantisColum

Post by mhonmon23 »

your mantis version?
NCDemonic
Posts: 2
Joined: 01 Feb 2011, 19:04

Re: BUG: CSVExport of a custom column (inherited MantisColum

Post by NCDemonic »

Our Mantis version is MantisBT Core 1.2.4
Post Reply