I have the views version from 08 March 2011.

In my view I have a filter based on an list named "field_kaz_options" with possible options 1, 2 and 3.

Now I cannot check this options anymore like in the versions before.

In the query he take this filter with LIKE

SELECT node.nid AS nid, node.title AS node_title, field_data_field_standort.field_standort_postcode AS field_data_field_standort_field_standort_postcode, field_data_field_standort.field_standort_city AS field_data_field_standort_field_standort_city, node.created AS node_created, 'node' AS field_data_field_kaz_image_node_entity_type, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_preis_node_entity_type, 'node' AS field_data_field_kaz_options_node_entity_type
FROM 
{node} node
LEFT JOIN {field_data_field_parked} field_data_field_parked ON node.nid = field_data_field_parked.entity_id AND (field_data_field_parked.entity_type = :views_join_condition_0 AND field_data_field_parked.deleted = :views_join_condition_1)
LEFT JOIN {field_data_field_kaz_options} field_data_field_kaz_options ON node.nid = field_data_field_kaz_options.entity_id AND (field_data_field_kaz_options.entity_type = :views_join_condition_2 AND field_data_field_kaz_options.deleted = :views_join_condition_3)
LEFT JOIN {field_data_field_standort} field_data_field_standort ON node.nid = field_data_field_standort.entity_id AND (field_data_field_standort.entity_type = :views_join_condition_4 AND field_data_field_standort.deleted = :views_join_condition_5)
WHERE (( (node.type IN  ('announce')) AND (node.status = '1') AND (field_data_field_parked.field_parked_value = '0') AND (field_data_field_kaz_options.field_kaz_options_value NOT LIKE '2' ESCAPE '\\') ))
GROUP BY nid
ORDER BY node_created DESC
LIMIT 20 OFFSET 0
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Can you please remove and add the filter again?
This should fix the problem.

klaus66’s picture

I have tried this but it doesn't work. Always the textfield and not the checkboxes in the UI.

I tested it with all my listfields and always the same result.

dawehner’s picture

Did you cleared the views cache on admin/structure/views/tools?

There might be problems there

klaus66’s picture

Of course I did.

bojanz’s picture

I reproduced this.
git blame says it's caused by commit:
#1079496 by dereine: Fix renamed field names for list fields. This caused an additional filter, which didn't worked.

The wrong handler gets chosen, not the filter_list one.
Which means that this code is failing:

function list_field_views_data($field) {
  $data = field_views_field_default_views_data($field);
  foreach ($data as $table_name => $table_data) {
    foreach ($table_data as $field_name => $field_data) {
      if (!in_array($field_name, array('table', $field_name, $field_name . '-revision_id'))) {
        $data[$table_name][$field_name]['filter']['handler'] = 'views_handler_filter_field_list';
      }
    }
  }
  return $data;
}

As far as I can see, that IF can never be true, since $field_name will always be in_array ;)

klaus66’s picture

FileSize
21.22 KB

Here is a screenshot

dawehner’s picture

Status: Active » Needs review
FileSize
952 bytes

Sorry sorry sorry.

Perhaps i should wait weeks to commit patches again.

klaus66’s picture

I have applied the patch and the listfilter works but I get the following notices (20 or more):

Notice: Undefined index: filter in list_field_views_data() (Zeile 292 von D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\modules\field.views.inc).
dawehner’s picture

Status: Needs review » Needs work

So needs work.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1012 bytes
845 bytes

Let's try two differnent approaches.

It would be cool if you could try the second one as well. This is slightly more advanced/safe's some code but needs extra review

klaus66’s picture

I applied the 1086158-filter-list-2.patch. I have done a short test with different list fields and I get no errors or notices.

I have an older views dev version on another server and there the function looks this and it works too:

<?php
function list_field_views_data($field) {
  $data = field_views_field_default_views_data($field);
  foreach ($data as $table_name => $table_data) {
    foreach ($table_data as $field_name => $field_data) {
      if (!in_array($field_name, array('table', 'entity_id', 'revision_id'))) {
        $data[$table_name][$field_name]['filter']['handler'] = 'views_handler_filter_field_list';
      }
    }
  }
  return $data;
}
?>
dawehner’s picture

The old code doesn't help, too :)


I applied the 1086158-filter-list-2.patch. I have done a short test with different list fields and I get no errors or notices.

Please test the first patch, too.

klaus66’s picture

I have tested now the first patch and it also works.

dawehner’s picture

Status: Needs review » Fixed

Thanks for testing the patch!

Commited the second one and pushed it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.