Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a view with all the fields provided by Scheduler and all the filters. With the filters set to NOT NULL for both fields, and the operator set to AND, I would have expected one of the entries not to show up, since the Unpublish on date is empty. Screenshots attached.
Comment | File | Size | Author |
---|---|---|---|
#4 | Screen shot 2011-01-31 at 9.47.50 AM.png | 26.69 KB | sillygwailo |
schedule-views-d7-publish-unpublish-fields-and-countdowns.PNG | 12.82 KB | sillygwailo | |
scheduler-view-fields-and-filters.PNG | 9.36 KB | sillygwailo |
Comments
Comment #1
sillygwailo(OK so maybe the original title was insane.)
Comment #2
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedThis is actually only a flag in the views filter api (
'allow empty' => TRUE
). The filtering is done by views. I don't know what could be wrong on our side. I will have to play with it a bit.Comment #3
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedI trying to figure this out. What operator are you talking about and how do you set it?
Comment #4
sillygwailoClick the re-arrange button in the filters list, then you'd get a section like the one attached in the screenshot. The operator is in the top left.
Comment #5
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedOh, OK. Didn't know that.
It looks like there are no NULL values. It does not even work with a single value. Gotta dig deeper...
Comment #6
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedThis does not work at all. The NOT NULL filter only works if both are not null (i.e. the node has no entry in the scheduler table at all). If at least one of the two dates is set the NOT NULL filter for the other value does not work. I am convinced that this has worked in D6, but I will have to verify that.
Steps to reproduce:
- create a node that has no scheduler dates set (node 1)
- create a node with publish_on set to a valid date (node 2)
- create a node with unpublish_on set to a valid date (node 3)
- create a view with node:title, scheduler:publish_on and scheduler:unpublish_on
- filter for scheduler:unpublish_on NOT NULL
-> Nodes 2 and 3 are visible in the view, although 1 AND 2 should be filtered out
I even tried all kinds of hack in scheduler_node_load, like not setting the values if they are empty and setting them to NULL explicitly, but to no avail.
Comment #7
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedSame thing in D6.
Comment #8
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedI think we will have to introduce NULL into the db columns (they are NOT NULL right now). This might break lots of other stuff (scheduler_node_load() comes to mind). I'd rather not do that now. I guess we can leave that for post one-oh, because it actually mimics the D6 behavior, where this is also broken. Opinions?
Comment #9
jonathan1055 CreditAttribution: jonathan1055 commentedI mentioned in #1052002: Compare D7 hook_node_validate/presave with D6 hook_nodeapi(op=validate/presave) that I think storing unused dates as NULL would be preferrable. For expediency I think it is better to mimic the D6 behavior now, and get a D7 version out and being used. Then we can do the table update and code change as a separate task.
Comment #10
Eric-Alexander Schaefer CreditAttribution: Eric-Alexander Schaefer commentedComment #11
jonathan1055 CreditAttribution: jonathan1055 commentedSetting this back to active. It was forgotten for 7.x-1.1 but it does need to be fixed as it is definitely a bug and gives the wrong behaviour. I agree with Eric that we should consider storing 'no date' as null not zero.
#2022919: Sorting by publish_on gives wrong result if unpublish_on is present is another example of this problem.
Comment #12
jonathan1055 CreditAttribution: jonathan1055 commentedOK, here is a quick review following a read through of the code to find the changes required for storing empty dates as null instead of zero:
So it might not be as difficult as we first thought. There are also several places where the existing code will work ok after the db change, but can be simplified to make it more readable.
Comment #13
jonathan1055 CreditAttribution: jonathan1055 commentedMoving this to the D8 queue. My review in #12 above showed that the work does not seem too tricky, but before proceeding to start this in D7 we need to have a discussion on how the dates (and indeed the entire Scheduler table) might be changed for D8. We can then agree on the best steps to fix this - as I think it's clear from this thread that storing 'no date' as zero is not the best.
Comment #14
jonathan1055 CreditAttribution: jonathan1055 commentedNow that #2498203: Use field storage rather than a custom table is the method we are using for Drupal 8, this issue is no longer relevent for 8.x, so moving back to 7.x
Comment #15
jonathan1055 CreditAttribution: jonathan1055 commentedThis wont be change in the 7.x version now.