View Issue Details

IDProjectCategoryView StatusLast Update
0011561mantisbtcustom fieldspublic2010-08-16 07:52
ReporterOlaf123 Assigned Todhx  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.0 
Target Version1.2.1Fixed in Version1.2.1 
Summary0011561: Filtering for custom field types multilist and checkbox does not work
Description

When I create a checkbox or multi select list, I can't get the filter to work on it.

Steps To Reproduce

  • Create a checkbox custom field called MyFlag with a possible field value Flag.
  • Add it to your project.
  • Turn on the check box by editing some of your issues.
  • Go to the view issues list and filter MyFlag for value Flag

No issues will be returned

Additional Information

Using xdebug and eclipse I found that the multilist and the checkbox are treated different from other custom fields. There implementation is exactly the same though. The exception causes the faillure. By replacing the switch case statement at line 1899 in filter_api.php
switch( $t_def['type'] ) {
case CUSTOM_FIELD_TYPE_MULTILIST:
case CUSTOM_FIELD_TYPE_CHECKBOX:
$t_where_params[] = '%|' . $t_filter_member . '|%';
array_push( $t_filter_array, db_helper_like( "$t_table_name.value" ) );
break;
default:
array_push( $t_filter_array, "$t_table_name.value =
'" . db_prepare_string( $t_filter_member ) . "'" );
}
into just the default case
array_push( $t_filter_array, "$t_table_name.value =
'" . db_prepare_string( $t_filter_member ) . "'" );
full functionality is restored.

TagsNo tags attached.

Relationships

has duplicate 0010901 closeddhx We can't use & in custom field value and it's impossible search the first and last value from custom list 
has duplicate 0009685 closeddhx Custom fields of type "Checkbox" not filtered correctly 
has duplicate 0010194 closeddhx Filtering by Radio type custom field doesn't find anything 

Activities

dhx

dhx

2010-03-04 08:00

reporter   ~0024634

Thanks for reporting this problem - it is now fixed :)

BTW we can't just use the approach you listed by removing the LIKE clauses. Why? A value may be "option1|option2|option3" as stored in mantis_custom_field_string_table and therefore we can't just check if this column is equal to say "option2"... as "option2" may occur mid-way through the vertical pipe delimited string.

My patch should work for all cases with multi-selection custom fields.

Saying that, the current database storage approach for multi-select custom field types is horrible! The performance hit of needing to use multiple LIKE statements is of a real concern. In the future this is something I hope we can resolve.

Olaf123

Olaf123

2010-03-04 08:39

reporter   ~0024636

Thanks for fixing this so soon. I'll use your patch.

Related Changesets

MantisBT: master-1.2.x b03397ad

2010-03-04 07:49

dhx


Details Diff
Fix 0011561: Filtering fails for multi-select custom field types

When attempting to filter bugs based on multi-select custom fields, some
bugs are not returned. This is due to multi-select custom field values
being stored as a string in the database with a vertical pipe character
being used as a delimiter between values. We can't just check for:

LIKE '%|value|%'

We also need to check for:

LIKE 'value|%'
LIKE '%|value'
= 'value'

To catch all possible cases of a value being stored within a
multi-select custom field string.
Affected Issues
0011561
mod - core/database_api.php Diff File
mod - core/filter_api.php Diff File

MantisBT: master 73d72e11

2010-03-04 07:49

dhx


Details Diff
Fix 0011561: Filtering fails for multi-select custom field types

When attempting to filter bugs based on multi-select custom fields, some
bugs are not returned. This is due to multi-select custom field values
being stored as a string in the database with a vertical pipe character
being used as a delimiter between values. We can't just check for:

LIKE '%|value|%'

We also need to check for:

LIKE 'value|%'
LIKE '%|value'
= 'value'

To catch all possible cases of a value being stored within a
multi-select custom field string.
Affected Issues
0011561
mod - core/filter_api.php Diff File
mod - core/database_api.php Diff File

MantisBT: master 4c1a2785

2010-03-12 06:34

dhx


Details Diff
Fix 0011561: Database storage format of CF multilist, checkbox and radio types

Once upon a time multi-select custom field types (checkbox and
multiselect) were stored in the database in the format of
"option1|option2|option3" where they should have been stored in a format
of "|option1|option2|option3|". Additionally, radio custom field types
were being stored in the database with an unnecessary vertical pipe
prefix and suffix when there is only ever one possible value that can be
assigned to a radio field.

This patch introduces a new schema upgrade function that corrects the
invalid storage of checkbox, multiselect and radio custom fields in the
database.
Affected Issues
0011561
mod - core/install_helper_functions_api.php Diff File
mod - admin/schema.php Diff File

MantisBT: master-1.2.x b57e7449

2010-03-12 06:34

dhx


Details Diff
Fix 0011561: Database storage format of CF multilist, checkbox and radio types

Once upon a time multi-select custom field types (checkbox and
multiselect) were stored in the database in the format of
"option1|option2|option3" where they should have been stored in a format
of "|option1|option2|option3|". Additionally, radio custom field types
were being stored in the database with an unnecessary vertical pipe
prefix and suffix when there is only ever one possible value that can be
assigned to a radio field.

This patch introduces a new schema upgrade function that corrects the
invalid storage of checkbox, multiselect and radio custom fields in the
database.
Affected Issues
0011561
mod - admin/install_functions.php Diff File
mod - admin/schema.php Diff File

MantisBT: master 375a337d

2010-03-12 06:42

dhx


Details Diff
Various custom field validation, filtering and performance fixes

This commit is a roll-up of various bug fixes related to custom field
implementations within MantisBT. In particular, multilist, checkbox and
radio fields now work as expected when creating and updating bug reports
as well as upon filtering on these custom field types.

Fix 0011628: Checkbox custom field should allow no selections
Fix 0011561: Reimplement an earlier patch to improve performance
Fix 0011610: Reimplement custom field validation logic (see 0011628)
Affected Issues
0010482, 0011561, 0011610, 0011628
mod - api/soap/mc_issue_api.php Diff File
mod - core/custom_field_api.php Diff File
mod - core/cfdefs/cfdef_standard.php Diff File
mod - bug_update.php Diff File
mod - bug_report.php Diff File
mod - core/filter_api.php Diff File

MantisBT: master-1.2.x bbe690f3

2010-03-12 06:42

dhx


Details Diff
Various custom field validation, filtering and performance fixes

This commit is a roll-up of various bug fixes related to custom field
implementations within MantisBT. In particular, multilist, checkbox and
radio fields now work as expected when creating and updating bug reports
as well as upon filtering on these custom field types.

Fix 0011628: Checkbox custom field should allow no selections
Fix 0011561: Reimplement an earlier patch to improve performance
Fix 0011610: Reimplement custom field validation logic (see 0011628)
Affected Issues
0010482, 0011561, 0011610, 0011628
mod - bug_report.php Diff File
mod - core/custom_field_api.php Diff File
mod - api/soap/mc_issue_api.php Diff File
mod - bug_update.php Diff File
mod - core/cfdefs/cfdef_standard.php Diff File
mod - core/filter_api.php Diff File