From 85fbfe3e6388957c51273e8cfeb60e574c9373fb Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 30 Jan 2024 16:18:42 +0200 Subject: [PATCH] fix not updated jpegphoto, if changed in AD --- api/src/Accounts/Import.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/api/src/Accounts/Import.php b/api/src/Accounts/Import.php index e8790d9324..6d83cf25ad 100644 --- a/api/src/Accounts/Import.php +++ b/api/src/Accounts/Import.php @@ -423,6 +423,7 @@ class Import // photo and public keys are not stored in SQL but in filesystem, fetch it to compare $contact['files'] = 0; if ($contact['jpegphoto'] === false) $contact['jpegphoto'] = null; + Api\Vfs::$is_root = true; foreach($this->files2attrs as $file => [$attr, $mask, $regexp]) { if (isset($contact[$attr])) @@ -439,6 +440,7 @@ class Import } $last_attr = $attr; } + Api\Vfs::$is_root = false; $to_update = array_merge($sql_contact, array_filter($contact, static function ($attr) { return $attr !== null && $attr !== ''; })); @@ -471,16 +473,17 @@ class Import } Api\Vfs::$is_root = false; */ - // photo_unchanged=true must be set, to no delete the photo, if it's not in LDAP - $this->contacts_sql->data['photo_unchanged'] = !isset($diff['files']) || - ($to_update['files']&Api\Contacts::FILES_BIT_PHOTO) === ($sql_contact['files']&Api\Contacts::FILES_BIT_PHOTO); + // photo_unchanged=true must be set, to not delete the photo, if it's not in LDAP + $diff['photo_unchanged'] = $this->contacts_sql->data['photo_unchanged'] = + !isset($diff['jpegphoto']) && (!isset($diff['files']) || + ($to_update['files']&Api\Contacts::FILES_BIT_PHOTO) === ($sql_contact['files']&Api\Contacts::FILES_BIT_PHOTO)); if ($need_update && $this->contacts_sql->save($to_update)) { $this->logger("Error updating contact data of '$account[account_lid]' (#$account_id)", 'error'); ++$errors; continue; } - $hide_binary = !empty($contact['jpegphoto']) ? ['jpegphoto' => bytes($contact['jpegphoto']).' bytes binary data'] : []; + $hide_binary = !empty($diff['jpegphoto']) ? ['jpegphoto' => bytes($diff['jpegphoto']).' bytes binary data'] : []; $this->logger("Successful updated contact data of '$account[account_lid]' (#$account_id): ". json_encode($hide_binary+$diff, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE), 'detail'); if (!$new) $new = false;