$result = $query->execute();
while ($row = $result->fetch()) {
$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;
}
$result->closeCursor();
return false;
}
$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;
}
while ($row = $result->fetch()) {
$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;
}
$result->closeCursor();
]);
}
- private function readBlob($cardData) {
+ /**
+ * @param resource|string $cardData
+ * @param bool $modified
+ * @return string
+ */
+ private function readBlob($cardData, &$modified=false) {
if (is_resource($cardData)) {
$cardData = stream_get_contents($cardData);
}
&& strpos($line, 'PHOTO:data:image/') !== 0) {
// Filter out PHOTO data of non-images
$removingPhoto = true;
+ $modified = true;
continue;
}
$result->closeCursor();
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;
}, $cards);
}
$queryResult->closeCursor();
if (is_array($contact)) {
+ $modified = false;
$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;
}