From 102daa151e2cef8bc511a166b2cd64eba32dbed6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Thu, 4 Aug 2016 14:40:17 +0200
Subject: [PATCH] Fixes #4945 Support template filling in DateAttribute

---
 include/simpleplugin/class_attribute.inc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/simpleplugin/class_attribute.inc b/include/simpleplugin/class_attribute.inc
index b1d0e7631..ce22c8398 100644
--- a/include/simpleplugin/class_attribute.inc
+++ b/include/simpleplugin/class_attribute.inc
@@ -1488,9 +1488,17 @@ class DateAttribute extends Attribute
     if ($this->value === "" && !$this->isRequired()) {
       return $this->value;
     } elseif (!($this->value instanceof DateTime)) {
-      $this->setValue($this->getDateValue());
+      try {
+        $this->setValue($this->getDateValue());
+        return $this->dateToLdap($this->value);
+      } catch (Exception $e) {
+        if (is_object($this->plugin) && $this->plugin->is_template) {
+          return $value;
+        } else {
+          throw $e;
+        }
+      }
     }
-    return $this->dateToLdap($this->value);
   }
 
   function check ()
-- 
GitLab