From b8cfa0d02f036a16fea089c6a943da73125f575b Mon Sep 17 00:00:00 2001 From: Drew Johnston Date: Wed, 11 May 2016 15:27:10 -0500 Subject: [PATCH] Do not set our due parameter if empty/null Trello tries to set a due date if we provide the parameter at all; so if it is set but is empty, we need to unset it. --- lib/Trello/Api/Card.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Trello/Api/Card.php b/lib/Trello/Api/Card.php index 5c45e16..9208758 100644 --- a/lib/Trello/Api/Card.php +++ b/lib/Trello/Api/Card.php @@ -103,6 +103,14 @@ public function create(array $params = array()) */ public function update($id, array $params = array()) { + // If the due date is set, but is empty, remove it from the fields that are sent in the request. + // This prevents Trello from adding a "X set this card to be due Invalid date" comment. + foreach($params as $param_name => $param_value) { + if($param_name == 'due' && empty($param_value)) { + unset($params[$param_name]); + } + } + return $this->put($this->getPath().'/'.rawurlencode($id), $params); }