Skip to content

ContactManager CreateOrUpdate function messes up contact #20544

@call-me-matt

Description

@call-me-matt

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Background

Hey, I am trying to modify a contact within an app-controller, but for some reason the modified contacts are messed up during the storage process. I looked at the sources, but could not find out if its a bug or just me misunderstanding the headers. Tried to search in the documentation, but only found an empty page at https://docs.nextcloud.com/server/latest/developer_manual/api.html . That brings me here...

Steps to reproduce

  1. grab a contact $contact = $addressBook->search($contactId, ['UID'], [])[0];
  2. make a copy $changed = $contact;
  3. change it (or not)
  4. save it $addressBook->createOrUpdate($changed);
  5. verify: $addressBook->search($contactId, ['UID'], [])[0];

Expected behaviour

The contact is changed (or not) and remains with correct syntax.

Actual behaviour

The contact fields are not as expected:

the contact:
array(9) { ["URI"]=> string(40) "EBD3B9AA-FC6E-45DF-9294-C069141DA1F0.vcf" ["VERSION"]=> string(3) "4.0" ["PRODID"]=> string(28) "-//Nextcloud Contacts v3.2.0" ["UID"]=> string(36) "5ee6e61a-e281-47c6-ab17-11fb37bb7740" ["REV"]=> string(16) "20200417T190130Z" ["FN"]=> string(4) "Test" ["ADR"]=> string(6) ";;;;;;" ["EMAIL"]=> array(1) { [0]=> string(0) "" } ["TEL"]=> array(1) { [0]=> string(0) "" } }

the updated contact (identical):
array(9) { ["URI"]=> string(40) "EBD3B9AA-FC6E-45DF-9294-C069141DA1F0.vcf" ["VERSION"]=> string(3) "4.0" ["PRODID"]=> string(28) "-//Nextcloud Contacts v3.2.0" ["UID"]=> string(36) "5ee6e61a-e281-47c6-ab17-11fb37bb7740" ["REV"]=> string(16) "20200417T190130Z" ["FN"]=> string(4) "Test" ["ADR"]=> string(6) ";;;;;;" ["EMAIL"]=> array(1) { [0]=> string(0) "" } ["TEL"]=> array(1) { [0]=> string(0) "" } }

the return value of the update function (identical):
array(9) { ["URI"]=> string(40) "EBD3B9AA-FC6E-45DF-9294-C069141DA1F0.vcf" ["VERSION"]=> string(3) "4.0" ["PRODID"]=> string(28) "-//Nextcloud Contacts v3.2.0" ["UID"]=> string(36) "5ee6e61a-e281-47c6-ab17-11fb37bb7740" ["REV"]=> string(16) "20200417T190130Z" ["FN"]=> string(4) "Test" ["ADR"]=> string(6) ";;;;;;" ["EMAIL"]=> array(1) { [0]=> string(0) "" } ["TEL"]=> array(1) { [0]=> string(0) "" } }

but the stored contact (not identical, see ADR):
array(9) { ["URI"]=> string(40) "EBD3B9AA-FC6E-45DF-9294-C069141DA1F0.vcf" ["VERSION"]=> string(3) "4.0" ["PRODID"]=> string(28) "-//Nextcloud Contacts v3.2.0" ["UID"]=> string(36) "5ee6e61a-e281-47c6-ab17-11fb37bb7740" ["REV"]=> string(16) "20200417T190130Z" ["FN"]=> string(4) "Test" ["ADR"]=> string(18) "\;\;\;\;\;\;;;;;;;" ["EMAIL"]=> array(1) { [0]=> string(0) "" } ["TEL"]=> array(1) { [0]=> string(0) "" } }

Also trying the types-option did not change things $contact = $addressBook->search($contactId, ['UID'], ['types' => true])[0];, as the function seems to convert the array to vCard. For me it looks like there is a bug happening somewhere behind that.

Server configuration

latest nextcloud docker on ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions