Fix/date profile field types (#6183)

* Fix Date and Datetime profile field type with null values on PHP 8.1+

* Update CHANGELOG.md

* Avoid possible null value
This commit is contained in:
Yuriy Bakhtin 2023-03-21 16:36:39 +04:00 committed by GitHub
parent 53749a129e
commit bb0d8a5f1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -333,7 +333,7 @@ class LdapAuth extends BaseFormAuth implements AutoSyncUsers, SyncAttributes, Ap
foreach ($normalized as $name => $value) {
if (isset(Yii::$app->params['ldap']['dateFields'][$name]) && $value != '') {
$dateFormat = Yii::$app->params['ldap']['dateFields'][$name];
$date = DateTime::createFromFormat($dateFormat, $value);
$date = DateTime::createFromFormat($dateFormat, $value ?? '');
if ($date !== false) {
$normalized[$name] = $date->format('Y-m-d');