LSattr_ldap::pwdHistory: fix fatal error on time encoding.

This commit is contained in:
Benjamin Renard 2020-12-21 14:54:37 +01:00
parent 114e3c48ac
commit 1428b5df62

View file

@ -89,6 +89,10 @@ class LSattr_ldap_pwdHistory extends LSattr_ldap {
return; return;
} }
$datetime = date_create_from_format('YmdHisO', $value['time']); $datetime = date_create_from_format('YmdHisO', $value['time']);
if (!is_a($datetime, 'DateTime')) {
self :: log_warning($this."->encodeValue($value): Fail to create DateTime object from timestamp '".varDump($value['time'])."'.");
return;
}
$datetime -> setTimezone('UTC'); $datetime -> setTimezone('UTC');
$datetime_string = $datetime -> format('YmdHisO'); $datetime_string = $datetime -> format('YmdHisO');
$datetime_string = preg_replace('/[\+\-]0000$/', 'Z', $datetime_string); $datetime_string = preg_replace('/[\+\-]0000$/', 'Z', $datetime_string);