diff --git a/lib/Plugin.php b/lib/Plugin.php index 449c718..c9377f8 100644 --- a/lib/Plugin.php +++ b/lib/Plugin.php @@ -188,9 +188,12 @@ class Plugin extends ServerPlugin { $body = $request->getBodyAsString(); $path = $request->getPath(); $paths = explode('/', $path); - if (sizeof($paths) > 1) { + if (isset($paths) && sizeof($paths) > 1) { $uid = str_replace('.ics', '', $paths[sizeof($paths)-1]); - $this->storageManager->remove($uid); + // Check if deleting an ics file + if ($uid != '') { + $this->storageManager->remove($uid); + } } } catch(BadRequest $e){ throw new BadRequest($e->getMessage(), null, $e); diff --git a/lib/Storages/Taskwarrior.php b/lib/Storages/Taskwarrior.php index 8edd475..40badaf 100644 --- a/lib/Storages/Taskwarrior.php +++ b/lib/Storages/Taskwarrior.php @@ -209,6 +209,10 @@ class Taskwarrior implements IStorage { try { $this->logger->info(sprintf('Deleting iCal %s from taskwarrior', $uid)); $this->refresh(); + if (!array_key_exists((string)$uid, $this->tasks)) { + $this->logger->warn(sprintf('Could not find task %s to delete. Skipping', (string)$uid)); + return; + } $task = $this->tasks[(string)$uid]; if (isset($task) && $task['status'] !== 'deleted') { $uuid = $task['uuid'];