Bugfix: TypeError: Return value of PdoAddressBook::davClientRequest()

For #79
This commit is contained in:
djmaze 2021-04-16 11:57:06 +02:00
parent 31bc2850de
commit f36ef03c1e
2 changed files with 12 additions and 14 deletions

View file

@ -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

View file

@ -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);