Hey All,

I recently did an upgrade of views from 6.x.2.10 to 6.x.2.16 for a client and then found out later on a number of the existing views setup on their site which where using exposed filters stopped working properly. After comparing the old version to the new one I noticed in the exposed filter form the "Optional" checkbox is no longer there.

Is this intentional? I need to know if this is a bug or not and if this functionality was removed on purpose then I'm going to have to roll back to a reversion which provided this functionality.

Any help or direction would be very helpful and appreciated!

Cheers,
Gene Bernier

CommentFileSizeAuthor
#24 views-6.x-2.16.patch727 bytesyingtho
#23 views-6.x-2.16.patch754 bytesyingtho
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

It depends on the filter.

The 'Optional' checkbox was removed for string filters where the checkbox has no meaning to avoid confusion. Removing this checkbox should not have changed anything, since these filters were always optional anyway.

You'll have to provide specific filter information to get a more detailed answer, since there are hundreds of them.

merlinofchaos’s picture

As a side note, posting the same message as a new issue AND cut & pasting the text into an old issue and hijacking it is frowned upon. Please don't do that. It's incredibly inconsiderate.

gbernier’s picture

Status: Postponed (maintainer needs more info) » Active

After digging through the release notes between 2.16 and 2.10, found where in 2.6.14 this functionality was removed for string exposed filters, http://drupal.org/node/1329846. Here is the issue it's related too http://drupal.org/node/1054272

From the notes on the original issue, it reads as if the intent is if the filters are blank they should be automatically be optional. In this case on the 6.2.16 version we keep getting no results returned.

The difference in the Where clauses is this is add "AND (1<>1)" on the 6.2.16 version and it's not there on the 6.1.10 version.

Running the SQL manually and removing the AND (1<>1) gets the results returned properly from MYSQL. Any help or idea what is putting that in to the SQL would be a huge help to get this resolved.

Cheers,
Gene Bernier

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Please provide the information requested in #1.

gbernier’s picture

Status: Postponed (maintainer needs more info) » Active

Hey Merlin,

I had mistakenly posted that comment on the other issue and was trying to delete it when I realized what had occured, that was my way of trying to clean it out and start a new thread of discussion. As a pure accident

gbernier’s picture

The issue as I pointed out in #3 is the now inclusion of this (1<>1) in the where clause now that's new between the two versions

"WHERE ((node.type in ('part_vehicle')) AND (node_node_data_field_vehicle.nid = 6687 ) AND (1<>1))"

The fields are content fields, they are all string based fields, and are exposed. The view is setup to continue listing out nodes until the user selects a single node, then it's passed in as an argument. What is happening is when because of the inclusion of the 1<>1 when the argument is included a single result does not show up.

Hope that makes sense.

gbernier’s picture

Thanks for the help and advice as well Merlin!

merlinofchaos’s picture

Well, that particular WHERE clause normally only comes from something like the Search: Terms filter, which is part of why I was asking specifically what filter.

There is nothing in the basic content filter that adds that kind of clause, and if you're not using the search terms filter, it's not clear to me where it might be coming from.

What's really interesting to me is the spacing. I am really nitpicky about the formatting in SQL. I would never put spacing like that, and when Views forms a filter normally, it will always put spaces around the operator. So a query like that would have to done kind of manually.

gbernier’s picture

Here are the two full versions of what is generated between the two revisions

16

Select node.nid as nid, node_node_data_field_vehicle_node_data_field_manufacturer.field_manufacturer_value AS node_node_data_field_vehicle_node_data_field_manufacturer_field_manufacturer_value, node_node_data_field_vehicle.nid AS node_node_data_field_vehicle_nid, node_node_data_field_vehicle.type AS node_node_data_field_vehicle_type, node_node_data_field_vehicle.vid AS node_node_data_field_vehicle_vid, node_node_data_field_vehicle_node_data_field_manufacturer.field_model_value AS node_node_data_field_vehicle_node_data_field_manufacturer_field_model_value, node_node_data_field_vehicle_node_data_field_manufacturer.field_variant_value AS node_node_data_field_vehicle_node_data_field_manufacturer_field_variant_value, node_data_field_position.field_position_value AS node_data_field_position_field_position_value, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_node_data_field_part_node_data_field_shape_set_web.field_shape_set_web_value AS node_node_data_field_part_node_data_field_shape_set_web_field_shape_set_web_value, node_node_data_field_part.nid AS node_node_data_field_part_nid, node_node_data_field_part.type AS node_node_data_field_part_type, node_node_data_field_part.vid AS node_node_data_field_part_vid, node_node_data_field_part_node_data_field_shape_set_web.field_webimage_value AS node_node_data_field_part_node_data_field_shape_set_web_field_webimage_value, node_node_data_field_part_node_data_field_shape_set_web.field_webpdf_value AS node_node_data_field_part_node_data_field_shape_set_web_field_webpdf_value, node_node_data_field_vehicle_node_data_field_model.field_model_value AS node_node_data_field_vehicle_node_data_field_model_field_model_value, node_node_data_field_vehicle_node_data_field_model.field_variant_value AS node_node_data_field_vehicle_node_data_field_model_field_variant_value, node_node_data_field_vehicle_node_data_field_model.field_date_value AS node_node_data_field_vehicle_node_data_field_model_field_date_value FROM node node LEFT JOIN content_type_part_vehicle node_data_field_part ON node.vid = node_data_field_part.vid LEFT JOIN node node_node_data_field_part ON node_data_field_part.field_part_nid = node_node_data_field_part.nid LEFT JOIN content_type_part_vehicle node_data_field_vehicle ON node.vid = node_data_field_vehicle.vid LEFT JOIN node node_node_data_field_vehicle ON node_data_field_vehicle.field_vehicle_nid = node_node_data_field_vehicle.nid LEFT JOIN content_type_vehicle node_node_data_field_vehicle_node_data_field_manufacturer ON node_node_data_field_vehicle.vid = node_node_data_field_vehicle_node_data_field_manufacturer.vid LEFT JOIN content_type_part_vehicle node_data_field_position ON node.vid = node_data_field_position.vid LEFT JOIN content_type_part node_node_data_field_part_node_data_field_shape_set_web ON node_node_data_field_part.vid = node_node_data_field_part_node_data_field_shape_set_web.vid LEFT JOIN content_type_vehicle node_node_data_field_vehicle_node_data_field_model ON node_node_data_field_vehicle.vid = node_node_data_field_vehicle_node_data_field_model.vid
WHERE ((node.type in ('part_vehicle')) AND (node_node_data_field_vehicle.nid = 6687 ) AND (1<>1)) AND (node_node_data_field_part_node_data_field_shape_set_web.field_shape_status_value = 'Active')
ORDER BY node_node_data_field_vehicle_node_data_field_model_field_model_value ASC, node_node_data_field_vehicle_node_data_field_model_field_variant_value ASC, node_node_data_field_vehicle_node_data_field_model_field_date_value ASC, node_data_field_position_field_position_value ASC

10
SELECT node.nid AS nid, node_node_data_field_vehicle_node_data_field_manufacturer.field_manufacturer_value AS node_node_data_field_vehicle_node_data_field_manufacturer_field_manufacturer_value, node_node_data_field_vehicle.nid AS node_node_data_field_vehicle_nid, node_node_data_field_vehicle.type AS node_node_data_field_vehicle_type, node_node_data_field_vehicle.vid AS node_node_data_field_vehicle_vid, node_node_data_field_vehicle_node_data_field_manufacturer.field_model_value AS node_node_data_field_vehicle_node_data_field_manufacturer_field_model_value, node_node_data_field_vehicle_node_data_field_manufacturer.field_variant_value AS node_node_data_field_vehicle_node_data_field_manufacturer_field_variant_value, node_data_field_position.field_position_value AS node_data_field_position_field_position_value, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_node_data_field_part_node_data_field_shape_set_web.field_shape_set_web_value AS node_node_data_field_part_node_data_field_shape_set_web_field_shape_set_web_value, node_node_data_field_part.nid AS node_node_data_field_part_nid, node_node_data_field_part.type AS node_node_data_field_part_type, node_node_data_field_part.vid AS node_node_data_field_part_vid, node_node_data_field_part_node_data_field_shape_set_web.field_webimage_value AS node_node_data_field_part_node_data_field_shape_set_web_field_webimage_value, node_node_data_field_part_node_data_field_shape_set_web.field_webpdf_value AS node_node_data_field_part_node_data_field_shape_set_web_field_webpdf_value, node_node_data_field_vehicle_node_data_field_model.field_model_value AS node_node_data_field_vehicle_node_data_field_model_field_model_value, node_node_data_field_vehicle_node_data_field_model.field_variant_value AS node_node_data_field_vehicle_node_data_field_model_field_variant_value, node_node_data_field_vehicle_node_data_field_model.field_date_value AS node_node_data_field_vehicle_node_data_field_model_field_date_value FROM node node LEFT JOIN content_type_part_vehicle node_data_field_part ON node.vid = node_data_field_part.vid LEFT JOIN node node_node_data_field_part ON node_data_field_part.field_part_nid = node_node_data_field_part.nid LEFT JOIN content_type_part_vehicle node_data_field_vehicle ON node.vid = node_data_field_vehicle.vid LEFT JOIN node node_node_data_field_vehicle ON node_data_field_vehicle.field_vehicle_nid = node_node_data_field_vehicle.nid LEFT JOIN content_type_vehicle node_node_data_field_vehicle_node_data_field_manufacturer ON node_node_data_field_vehicle.vid = node_node_data_field_vehicle_node_data_field_manufacturer.vid LEFT JOIN content_type_part_vehicle node_data_field_position ON node.vid = node_data_field_position.vid LEFT JOIN content_type_part node_node_data_field_part_node_data_field_shape_set_web ON node_node_data_field_part.vid = node_node_data_field_part_node_data_field_shape_set_web.vid LEFT JOIN content_type_vehicle node_node_data_field_vehicle_node_data_field_model ON node_node_data_field_vehicle.vid = node_node_data_field_vehicle_node_data_field_model.vid
WHERE ((node.type in ('part_vehicle')) AND (node_node_data_field_vehicle.nid = 6687)) AND (node_node_data_field_part_node_data_field_shape_set_web.field_shape_status_value = 'Active')
ORDER BY node_node_data_field_vehicle_node_data_field_model_field_model_value ASC, node_node_data_field_vehicle_node_data_field_model_field_variant_value ASC, node_node_data_field_vehicle_node_data_field_model_field_date_value ASC, node_data_field_position_field_position_value ASC

gbernier’s picture

Yeah there is no terms filter at all on this view, it's got a Node:type which isn't exposed, then the following filters are exposed node:title, and two string content fields which are done through CCK. Those pieces work, but as soon as the argument for a Node:nid is passed in that 1<>1 shows up. The Argument is using a relationship as well.

calmforce’s picture

I have the same issue with Location fields in a node: for Location:Province the "optional" box shows up, so if I don't type name of a state, it shows all nodes. If I add "Location:Postal Code" exposed filter, there is no "optional" checkbox and there are no results if the exposed box is empty. Same thing for Location:City. Certainly it is unusable in such form, the intent is to narrow down the list by typing in city or zip code, not to have it empty until you apply the filter. What should I do - downgrade?

d4rkngel’s picture

same here :\ ... I'm using a textfield exposed filter from Profile module but is not optional as in previous views versions, the curious thing is that I have an old site wich I upgraded to the new Views version and it works fine, however the new site wich uses a clean installation of views reuses to use the exposed filter as optional adding this to the query:

AND (UPPER(profile_values_profile_municipio.value) = UPPER(''))
d4rkngel’s picture

a quick fix is to change this line in views_handler_filter_string.inc file

$options['expose']['contains']['optional'] = array('default' => FALSE);

to

$options['expose']['contains']['optional'] = array('default' => TRUE);

but I'm not sure if this can cause side effects

smithwib’s picture

I can confirm #12 - my preview SQL without the optional checkbox becomes:

AND (UPPER(node_data_field_mynode_test.field_mynode_test_value) = UPPER('')))

To fix, I did what was recommended in #13 and a few lines above set:

var $no_optional = FALSE;

That resolved it.

pwhite’s picture

Priority: Normal » Minor

Hi, I've just had the same problem and can confirm that the fixes in #13 and #14 have worked. thanks for the help.

gbernier’s picture

Hopefully this can become a patch and rolled into next release of views then.

dawehner’s picture

Changing any kind of default values are just a nogo as it has the potential to break a lot of drupal sites.

CraigBertrand’s picture

I have the same problem with a content profile cck text field.

I get empty results with nothing in the filter.

Going to apply #13/#14 until a fix is rolled out.

dmundra’s picture

Try using "Contains any word" or "Contains all words". I think those are intended to be used for searching optionally while the others are forced search. That is a guess. I need to read about it some more.

ikeigenwijs’s picture

I can confirm that number #13 and #14 did the trick for our project.
One a side note I tried to find the dev version of the 2.x tree but its not listed anymore, i read it should be fixed there.

dawehner’s picture

One a side note I tried to find the dev version of the 2.x tree but its not listed anymore, i read it should be fixed there.

You are right. The 2.x-dev is listed under all releases. People who can't figure out that, might should better use only stable versions.

DigitalFairy’s picture

I can confirm that number #13 and #14 are working also for us.

yingtho’s picture

FileSize
754 bytes

I'm confirm that i worked as well #13 and #14. Here is the enclosed patch.

yingtho’s picture

FileSize
727 bytes

I have enclosed an git patch, if the other ones deosn't work.

MustangGB’s picture

Issue summary: View changes
Status: Active » Closed (outdated)