From 8fbe7150484675e0911f386476d8770da4f12917 Mon Sep 17 00:00:00 2001 From: Michael J Rubinsky Date: Tue, 5 Jan 2016 21:03:13 -0500 Subject: [PATCH] Bug: 14214 Require a non-empty due date too. While we enfore this in Nag's UI, it wasn't enforced when adding tasks via the API - like from Kronolith, or external clients. Even though that is now fixed, we still include this requirement in the query to catch any existing tasks added like this. Note: We could use a migration for this, but there already exists newer migrations in master that make this difficult to handle. --- lib/Driver.php | 4 ++-- lib/Driver/Sql.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Driver.php b/lib/Driver.php index 5d5c0897..31495ba1 100644 --- a/lib/Driver.php +++ b/lib/Driver.php @@ -160,7 +160,7 @@ public function add(array $task) $result = Nag::sendNotification('add', $task); /* Add an alarm if necessary. */ - if (!empty($task->alarm) && + if (!empty($task->due) && !empty($task->alarm) && ($alarm = $task->toAlarm())) { $GLOBALS['injector']->getInstance('Horde_Alarm')->set($alarm); } @@ -302,7 +302,7 @@ public function modify($taskId, array $properties) /* Update alarm if necessary. */ $horde_alarm = $GLOBALS['injector']->getInstance('Horde_Alarm'); if ((isset($properties['alarm']) && empty($properties['alarm'])) || - !empty($properties['completed'])) { + !empty($properties['completed']) || empty($task->due)) { $horde_alarm->delete($task->uid); } else { $task = $this->get($taskId); diff --git a/lib/Driver/Sql.php b/lib/Driver/Sql.php index 20009b71..4434bb5c 100644 --- a/lib/Driver/Sql.php +++ b/lib/Driver/Sql.php @@ -519,9 +519,11 @@ public function getChildren($parentId, $include_history = true) */ public function listAlarms($date) { + // Check for non-empty alarm AND a non-empty due date. + // See Bug: 14214 $q = 'SELECT * FROM ' . $this->_params['table'] . ' WHERE task_owner = ?' . - ' AND task_alarm > 0' . + ' AND task_alarm > 0 AND task_due > 0' . ' AND (task_due - (task_alarm * 60) <= ?)' . ' AND task_completed = 0'; $values = array($this->_tasklist, $date);