I added a new message type category (#2059533: How to create a Message category?) to filter messages by category in views. This Bug occured:

If I add a filter by message type category and use IN with the just inserted message type category and there is no message type of that category created, the filter will not apply and all messages will be displayed. I think this is due to the fact that instead of filtering by message type category the filter is converted to a IN() of message types that are inside of that message type category.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Andre-B’s picture

I added the export of that view

Andre-B’s picture

Issue summary: View changes
Rob230’s picture

I can confirm that this is the case.

The issue is that the SQL query takes the form:

SELECT message.mid AS mid
FROM 
{message} message
WHERE ( message.type IN  ('test') )

If you have not created any message types for that particular category then the query won't have the WHERE clause, and thus will show all messages, such as those from other categories, which is incorrect behaviour.

It's not a major issue because really there shouldn't be cases on a production site where you have a message type category but no message types. It's the sort of thing that only occurs during development while you are setting things up.

Rob230’s picture

Here is a patch.

Rob230’s picture

That might need some more thinking through. I've only covered the case where the user chose 'in' for the operator. For the case where the user has chosen 'not in', I think the correct behaviour should be to change the operator to 'in'.

Rob230’s picture

Status: Active » Needs review
FileSize
1.1 KB

The last patch had a bug in it as well. Try this one.

bluegeek9’s picture

Status: Needs review » Closed (outdated)