Search returns not expected results


we would like to display only tasks for which due date is before today or is not set

we use the filter “due:none due:<=today” or “due:none due:<=2018-12-10”

but there are some tasks displayed that should not…

is there something we do wrong?

Thank you for your help



That won’t work.

if ($this->value == "none") {
            $this->query->eq(TaskModel::TABLE.'.date_due', 0);
        } else {
            $this->query->neq(TaskModel::TABLE.'.date_due', 0);

Your first query filters out every thing except those eq to 0.

The next query uses the results of your first query before it beings, and then filters out every thing it found. When it gets to neq to 0, and the result is nothing, the filter then shows every task as a result, including the closed tasks. The filters build on each other, they don’t combine.

You would need to build your own filter in order to filter what you want.

It would look something like:

$method = $this->parseOperator();
$timestamp = $this->dateParser->getTimestampFromIsoFormat($this->value);

            if ($method !== '') { $this->db
                ->eq('date_due', 0)
                ->$method('date_due', $this->getTimestampFromOperator($method, $timestamp))

You would apply it without listing the none, i.e. your_filter:<=today and it would show all tasks less than or equal to today, or eq to 0.


And here is a reference, to help you understand how to add your own filter:

Also, if you ask, I’ll help you out.


Thank you for your quick answer !!
I’ll have a look


If I understand well your link creecros/Creecros_Filter_Pack, you propose a plugin that adds new filters?

I can fork your source, add my custom filter then make a pull request?


Correct, but you don’t need to PR my repo. Just use my repo as a guide to make your own custom filter.


I tried, but without success for now.
I created a new class DateWithNull.php (code below)
I can call the filter with due_with_null:<today

it returns tasks with date_due=0, but also with date_due > today…
I don’t understand.

I activated the logs and I can see the SQL request : SELECT * FROM “tasks” WHERE (“date_due” = ? OR “date_due” < ?) (do you know how I can display the valuies for the placeholders?)
adding an error_log statement, I have :
[Mon Dec 10 20:04:06.664503 2018] [:error] [pid 8396] [client] Methode = lt
[Mon Dec 10 20:04:06.664537 2018] [:error] [pid 8396] [client] timestamp = 1544396400

executing the previous SQL with this timestamp returns the right tasks…

any idea to troubleshoot that?

Thank you for your help



  • Get search attribute
  • @access public
  • @return string[]
    public function getAttributes()
    return array(‘due_with_null’);


  • Apply filter
  • @access public
  • @return string
    public function apply()

$method = $this->parseOperator();
$timestamp = $this->dateParser->getTimestampFromIsoFormat($this->value);
error_log("Methode = " . $method);
error_log("timestamp = " . $this->getTimestampFromOperator($method, $timestamp));
if ($method !== ‘’) { $this->db
->eq(‘date_due’, 0)
->$method(‘date_due’, $this->getTimestampFromOperator($method, $timestamp))



send me collab and i’lll take care of it next chance i get for you


You’ll need to get the dateparser instance too when you initialize

$this->container->extend('taskLexer', function($taskLexer, $c) {
            return $taskLexer;



It works perfectly for myself.

it’s on a branch, so don’t use master

e.g. date_withnull:<=today


Hi Creecros,
indeed, it works well with your code, I didn’t includ a return statement in the apply function before.
thank you very much!!
Will you include this filter in you plugin?

Thank you again!!



I can include it if you so desire.


It would be nice if you could include it.

Thank you


Gérald Salin


Next chance I get to make a new release and update readme.



Whenever fred merges, it will be available for update.