Found a bug in the views filter on content lock in views_handler_filter_is_locked.inc
Not working:
class views_handler_filter_is_locked extends views_handler_filter_boolean_operator {
function query() {
$this->ensure_my_table();
if (empty($this->value)) {
$this->query->add_where($this->options['group'], "$this->table_alias.timestamp IS NULL");
}
else {
$this->query->add_where($this->options['group'], "$this->table_alias.timestamp IS NOT NULL");
}
}
}
Working
class views_handler_filter_is_locked extends views_handler_filter_boolean_operator {
function query() {
$this->ensure_my_table();
if (empty($this->value)) {
$this->query->add_where($this->options['group'], $this->table_alias.".timestamp", "NULL", "=");
}
else {
$this->query->add_where($this->options['group'], $this->table_alias.".timestamp", "NULL", "<>");
}
}
}
Relevant doc page: http://api.drupal.org/api/views/plugins!views_plugin_query_default.inc/f...
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | content_lock_null_filter_fix-1715400-8.patch | 745 bytes | deepdru |
| #7 | content_lock_null_filter_fix-1715400-7.patch | 896 bytes | gomez_in_the_south |
Comments
Comment #1
pandaski commentedComment #3
pandaski commentedThanks for contribution. Will be in next release very soon.
Comment #5
drummCorrecting issue status, see #2698635: Issue statuses changing by themselves?.
Comment #7
gomez_in_the_south commentedI found that the exposed Views filter for "Is locked" works when the value selected is "Any" or "True", but no rows are returned with a value of "False".
I'm using 7.x-2.2, though this seems to apply equally to the 7.x-3.x branch.
Steps to reproduce:
1. Create a View with an exposed filter on "Content Lock: Is Locked".
2. Set the filter to "Content Locked: False".
Expected behavior: Content that isn't locked would show in the list.
Actual behavior: No results are returned.
This appears to be related to how the "IS NULL / IS NOT NULL" matching happens. The attached patch works for me, though I am not sure if it can be considered DB agnostic, or would only work on MySQL databases.
I couldn't find documentation/examples on how to abstract "NULL" checks for the add_where portion of views query filters.
Comment #8
deepdru commentedExposed views filter for "is locked" works when the value selected is "Any" or "True". But no results returned with value "False" on 8.x-1.0.
Issue still exists on 8.x-1.0.
Comment #9
deepdru commentedHere is the patch to fix the views content filter issue.
Comment #10
deepdru commentedComment #11
nitheesh commented#9 works fine. Once you patch, make sure you have cleared the cache or a
drush crto make this work.Can be applied to 8.x-2.0