mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 03:29:20 +03:00
Bugfix: TypeError: Return value of PdoAddressBook::davClientRequest()
For #79
This commit is contained in:
parent
31bc2850de
commit
f36ef03c1e
2 changed files with 12 additions and 14 deletions
|
|
@ -79,7 +79,7 @@ trait CardDAV
|
|||
return $mResult;
|
||||
}
|
||||
|
||||
protected function davClientRequest(DAVClient $oClient, string $sCmd, string $sUrl, $mData = null) : ?array
|
||||
protected function davClientRequest(DAVClient $oClient, string $sCmd, string $sUrl, $mData = null) : ?\SnappyMail\HTTP\Response
|
||||
{
|
||||
\MailSo\Base\Utils::ResetTimeLimit();
|
||||
|
||||
|
|
@ -91,18 +91,17 @@ trait CardDAV
|
|||
// $this->oLogger->Write($mData, \MailSo\Log\Enumerations\Type::INFO, 'DAV');
|
||||
// }
|
||||
|
||||
$aResponse = null;
|
||||
try
|
||||
{
|
||||
if (('PUT' === $sCmd || 'POST' === $sCmd) && null !== $mData)
|
||||
{
|
||||
$aResponse = $oClient->request($sCmd, $sUrl, $mData, array(
|
||||
return $oClient->request($sCmd, $sUrl, $mData, array(
|
||||
'Content-Type' => 'text/vcard; charset=utf-8'
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$aResponse = $oClient->request($sCmd, $sUrl);
|
||||
return $oClient->request($sCmd, $sUrl);
|
||||
}
|
||||
|
||||
// if ('GET' === $sCmd)
|
||||
|
|
@ -115,7 +114,7 @@ trait CardDAV
|
|||
$this->oLogger->WriteException($oException);
|
||||
}
|
||||
|
||||
return $aResponse;
|
||||
return null;
|
||||
}
|
||||
|
||||
private function detectionPropFind(DAVClient $oClient, string $sPath) : ?array
|
||||
|
|
|
|||
|
|
@ -185,9 +185,9 @@ class PdoAddressBook
|
|||
if (0 < \strlen($mExsistenRemoteID))
|
||||
{
|
||||
$oResponse = $this->davClientRequest($oClient, 'GET', $sPath.$mExsistenRemoteID);
|
||||
if ($oResponse && isset($oResponse['headers'], $oResponse['body']))
|
||||
if ($oResponse)
|
||||
{
|
||||
$sExsistensBody = \trim($oResponse['body']);
|
||||
$sExsistensBody = \trim($oResponse->body);
|
||||
}
|
||||
|
||||
// $this->oLogger->WriteDump($sExsistensBody);
|
||||
|
|
@ -196,11 +196,10 @@ class PdoAddressBook
|
|||
$oResponse = $this->davClientRequest($oClient, 'PUT',
|
||||
$sPath.(0 < \strlen($mExsistenRemoteID) ? $mExsistenRemoteID : $oContact->CardDavNameUri()),
|
||||
$oContact->ToVCard($sExsistensBody, $this->oLogger)."\r\n\r\n");
|
||||
|
||||
if ($oResponse && isset($oResponse['headers'], $oResponse['headers']['etag']))
|
||||
if ($oResponse)
|
||||
{
|
||||
$sEtag = \trim(\trim($oResponse['headers']['etag']), '"\'');
|
||||
$sDate = !empty($oResponse['headers']['date']) ? \trim($oResponse['headers']['date']) : '';
|
||||
$sEtag = \trim(\trim($oResponse->getHeader('etag')), '"\'');
|
||||
$sDate = \trim($oResponse->getHeader('date'));
|
||||
if (!empty($sEtag))
|
||||
{
|
||||
$iChanged = empty($sDate) ? \time() : \MailSo\Base\DateTimeHelper::ParseRFC2822DateString($sDate);
|
||||
|
|
@ -227,9 +226,9 @@ class PdoAddressBook
|
|||
$aDatabaseSyncData[$sKey]['id_contact'] : '';
|
||||
|
||||
$oResponse = $this->davClientRequest($oClient, 'GET', $sPath.$aData['vcf']);
|
||||
if ($oResponse && isset($oResponse['headers'], $oResponse['body']))
|
||||
if ($oResponse)
|
||||
{
|
||||
$sBody = \trim($oResponse['body']);
|
||||
$sBody = \trim($oResponse->body);
|
||||
if (!empty($sBody))
|
||||
{
|
||||
$oContact = null;
|
||||
|
|
@ -244,7 +243,7 @@ class PdoAddressBook
|
|||
}
|
||||
|
||||
$oContact->PopulateByVCard($aData['uid'], $sBody,
|
||||
!empty($oResponse['headers']['etag']) ? \trim(\trim($oResponse['headers']['etag']), '"\'') : '',
|
||||
\trim(\trim($oResponse->getHeader('etag')), '"\''),
|
||||
$this->oLogger);
|
||||
|
||||
$this->ContactSave($sEmail, $oContact);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue