Skip to content
Snippets Groups Projects
Unverified Commit fe4527a8 authored by Georg Ehrke's avatar Georg Ehrke
Browse files

Update Contact Size after removing photo

parent 648c8df5
No related branches found
No related tags found
No related merge requests found
...@@ -501,7 +501,13 @@ class CardDavBackend implements BackendInterface, SyncSupport { ...@@ -501,7 +501,13 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$result = $query->execute(); $result = $query->execute();
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
$row['etag'] = '"' . $row['etag'] . '"'; $row['etag'] = '"' . $row['etag'] . '"';
$row['carddata'] = $this->readBlob($row['carddata']);
$modified = false;
$row['carddata'] = $this->readBlob($row['carddata'], $modified);
if ($modified) {
$row['size'] = strlen($row['carddata']);
}
$cards[] = $row; $cards[] = $row;
} }
$result->closeCursor(); $result->closeCursor();
...@@ -535,7 +541,12 @@ class CardDavBackend implements BackendInterface, SyncSupport { ...@@ -535,7 +541,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
return false; return false;
} }
$row['etag'] = '"' . $row['etag'] . '"'; $row['etag'] = '"' . $row['etag'] . '"';
$row['carddata'] = $this->readBlob($row['carddata']);
$modified = false;
$row['carddata'] = $this->readBlob($row['carddata'], $modified);
if ($modified) {
$row['size'] = strlen($row['carddata']);
}
return $row; return $row;
} }
...@@ -572,7 +583,13 @@ class CardDavBackend implements BackendInterface, SyncSupport { ...@@ -572,7 +583,13 @@ class CardDavBackend implements BackendInterface, SyncSupport {
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
$row['etag'] = '"' . $row['etag'] . '"'; $row['etag'] = '"' . $row['etag'] . '"';
$row['carddata'] = $this->readBlob($row['carddata']);
$modified = false;
$row['carddata'] = $this->readBlob($row['carddata'], $modified);
if ($modified) {
$row['size'] = strlen($row['carddata']);
}
$cards[] = $row; $cards[] = $row;
} }
$result->closeCursor(); $result->closeCursor();
...@@ -872,7 +889,12 @@ class CardDavBackend implements BackendInterface, SyncSupport { ...@@ -872,7 +889,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
]); ]);
} }
private function readBlob($cardData) { /**
* @param resource|string $cardData
* @param bool $modified
* @return string
*/
private function readBlob($cardData, &$modified=false) {
if (is_resource($cardData)) { if (is_resource($cardData)) {
$cardData = stream_get_contents($cardData); $cardData = stream_get_contents($cardData);
} }
...@@ -886,6 +908,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ...@@ -886,6 +908,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
&& strpos($line, 'PHOTO:data:image/') !== 0) { && strpos($line, 'PHOTO:data:image/') !== 0) {
// Filter out PHOTO data of non-images // Filter out PHOTO data of non-images
$removingPhoto = true; $removingPhoto = true;
$modified = true;
continue; continue;
} }
...@@ -952,7 +975,11 @@ class CardDavBackend implements BackendInterface, SyncSupport { ...@@ -952,7 +975,11 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$result->closeCursor(); $result->closeCursor();
return array_map(function ($array) { return array_map(function ($array) {
$array['carddata'] = $this->readBlob($array['carddata']); $modified = false;
$array['carddata'] = $this->readBlob($array['carddata'], $modified);
if ($modified) {
$array['size'] = strlen($array['carddata']);
}
return $array; return $array;
}, $cards); }, $cards);
} }
...@@ -1017,8 +1044,13 @@ class CardDavBackend implements BackendInterface, SyncSupport { ...@@ -1017,8 +1044,13 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$queryResult->closeCursor(); $queryResult->closeCursor();
if (is_array($contact)) { if (is_array($contact)) {
$modified = false;
$contact['etag'] = '"' . $contact['etag'] . '"'; $contact['etag'] = '"' . $contact['etag'] . '"';
$contact['carddata'] = $this->readBlob($contact['carddata']); $contact['carddata'] = $this->readBlob($contact['carddata'], $modified);
if ($modified) {
$contact['size'] = strlen($contact['carddata']);
}
$result = $contact; $result = $contact;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment