christian-putzke / Roundcube-CardDAV

Roundcube CardDAV Plugin
http://www.graviox.de
GNU Affero General Public License v3.0
119 stars 28 forks source link

Many contacts not synchronized #86

Open MrFly opened 9 years ago

MrFly commented 9 years ago

Hi,

synchronizing the contacts from SOGo does not work fully. There are only 23 contacts available in rouncube without any error or special log entry. At SOGo I get about 150-200 contacts or so. The 23 available contacts seem to be random. What can I do to find where (and why) this fails? Is there a way for debugging CardDAV plugin in a special way?

Thanks!

MrFly commented 9 years ago

Ok, did it myself. I digged a litte in the php code and found the problem: SOGo seems to not provide every vcard as a .vcf link. So the query to the server fails with an empty response. Problem is located at carddav_backend.php at method get_vcard():

public function get_vcard($vcard_id)
{
    $vcard_id = str_replace('.vcf', null, $vcard_id);
    $response = $this->query($this->url . $vcard_id . '.vcf', 'GET');

    return $response;
}

A workaround will be:

public function get_vcard($vcard_id)
{
    $vcard_id = str_replace('.vcf', null, $vcard_id);
    $response = $this->query($this->url . $vcard_id . '.vcf', 'GET');

    if (empty($response)) {
        $response = $this->query($this->url . $vcard_id, 'GET');
    }
    return $response;
}

So we simply have to try a second time without .vcf to get the vcard. This is not a real solution, because we should really try to avoid double requests, but works for now...