Fix: synchronous metadata retrieval is failing in strict mode
Metadata can now only be string or null. Fixes #1653
This commit is contained in:
parent
e4b8330e45
commit
6a3a78d023
3 changed files with 9 additions and 4 deletions
|
@ -227,7 +227,7 @@ protected function buildLinkDataFromUrl(Request $request, string $url): array
|
|||
|
||||
protected function buildFormData(array $link, bool $isNew, Request $request): array
|
||||
{
|
||||
$link['tags'] = strlen($link['tags']) > 0
|
||||
$link['tags'] = $link['tags'] !== null && strlen($link['tags']) > 0
|
||||
? $link['tags'] . $this->container->conf->get('general.tags_separator', ' ')
|
||||
: $link['tags']
|
||||
;
|
||||
|
|
|
@ -60,10 +60,15 @@ public function retrieve(string $url): array
|
|||
$title = mb_convert_encoding($title, 'utf-8', $charset);
|
||||
}
|
||||
|
||||
return [
|
||||
return array_map([$this, 'cleanMetadata'], [
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'tags' => $tags,
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
protected function cleanMetadata($data): ?string
|
||||
{
|
||||
return !is_string($data) || empty(trim($data)) ? null : trim($data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public function testFullRetrieval(): void
|
|||
$remoteCharset = 'utf-8';
|
||||
|
||||
$expectedResult = [
|
||||
'title' => $remoteTitle,
|
||||
'title' => trim($remoteTitle),
|
||||
'description' => $remoteDesc,
|
||||
'tags' => $remoteTags,
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue