View Issue Details

IDProjectCategoryView StatusLast Update
0010923mantisbtbugtrackerpublic2018-03-01 03:04
Reporterwschneider Assigned Tovboctor  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version1.2.0rc1 
Summary0010923: function history_log_event_direct should check (and eventually truncate) the length of the new and the old value
Description

We get an error if we submit tickets with custom fields (textfields) where the length of the text exceeds the length of 255 characters.

Additional Information

I patched the problem this was:

function history_log_event_direct( $p_bug_id, $p_field_name, $p_old_value, $p_new_value, $p_user_id = null, $p_type = 0 ) {

Only log events that change the value

if( $p_new_value != $p_old_value ) {
if( null === $p_user_id ) {
$p_user_id = auth_get_current_user_id();
}

$c_field_name = $p_field_name;
$c_old_value = ( is_null( $p_old_value ) ? '' : $p_old_value );
$c_new_value = ( is_null( $p_new_value ) ? '' : $p_new_value );
$c_bug_id = db_prepare_int( $p_bug_id );
$c_user_id = db_prepare_int( $p_user_id );
$c_type = db_prepare_int( $p_type );

#patch:
if ( strlen($c_old_value)>255 ) {
$c_old_value = substr($c_old_value,0,250) . "...";
}
if ( strlen($c_new_value)>255 ) {
$c_new_value = substr($c_new_value,0,250) . "...";
}
#end patch

$t_mantis_bug_history_table = db_get_table( 'mantis_bug_history_table' );

$query = "INSERT INTO $t_mantis_bug_history_table
( user_id, bug_id, date_modified, field_name, old_value, new_value, type )
VALUES
( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';

$result = db_query_bound( $query, Array( $c_user_id, $c_bug_id, db_now(), $c_field_name, $c_old_value, $c_new_value, $c_type ) );
}
}

Tagspatch

Relationships

related to 0006626 closeddaryn Support "Memo" custom field type 
related to 0024056 closedatrol Custom Fields of type "Textarea" cannot contain more than 255 chars due to bug_history table 

Activities

vboctor

vboctor

2009-09-11 22:14

manager   ~0022905

My assumption is that this is not a bug in the out of the box MantisBT. You will only hit the problem if the custom field allows more than 255 which means that you have another patch installed. Is that correct?

wschneider

wschneider

2009-09-14 01:55

reporter   ~0022910

You're right. It is the patch given in 0006626, which causes the described problem.