Skip to content

Commit

Permalink
[BUGFIX] Ensure online media without author works
Browse files Browse the repository at this point in the history
When an oembed provider does not send
an "author_name" property, then the request fails,
and there is a sys_file without a sys_file_metadata.

This then results that the show info popup does not work.

Resolves: #101877
Releases: main, 12.4, 11.5
Change-Id: If6ead0084664372b9133fdd544ede90aa8a0e5d7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80926
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
  • Loading branch information
bmack authored and bnf committed Sep 8, 2023
1 parent 288d84b commit 501b4f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
Expand Up @@ -414,27 +414,31 @@ protected function getPropertiesForTable(): array
$table = 'sys_file_metadata';
$metaDataRepository = GeneralUtility::makeInstance(MetaDataRepository::class);
/** @var array<string, string> $metaData */
$metaData = $metaDataRepository->findByFileUid($this->row['uid']);
$allowedFields = $this->getFieldList($table, (int)$metaData['uid']);
$metaData = $metaDataRepository->findByFileUid($this->row['uid'] ?? 0);

foreach ($metaData as $name => $value) {
if (in_array($name, $allowedFields, true)) {
if (!isset($GLOBALS['TCA'][$table]['columns'][$name])) {
continue;
}
// If there is no metadata record, skip it
if ($metaData !== []) {
$allowedFields = $this->getFieldList($table, (int)$metaData['uid']);

$isExcluded = !(!($GLOBALS['TCA'][$table]['columns'][$name]['exclude'] ?? false) || $this->getBackendUser()->check('non_exclude_fields', $table . ':' . $name));
if ($isExcluded) {
continue;
}
foreach ($metaData as $name => $value) {
if (in_array($name, $allowedFields, true)) {
if (!isset($GLOBALS['TCA'][$table]['columns'][$name])) {
continue;
}

$label = $lang->sL(BackendUtility::getItemLabel($table, $name));
$label = $label ?: $name;
$isExcluded = !(!($GLOBALS['TCA'][$table]['columns'][$name]['exclude'] ?? false) || $this->getBackendUser()->check('non_exclude_fields', $table . ':' . $name));
if ($isExcluded) {
continue;
}

$propertiesForTable['fields'][] = [
'fieldValue' => BackendUtility::getProcessedValue($table, $name, $metaData[$name], 0, false, false, (int)$metaData['uid']),
'fieldLabel' => htmlspecialchars($label),
];
$label = $lang->sL(BackendUtility::getItemLabel($table, $name));
$label = $label ?: $name;

$propertiesForTable['fields'][] = [
'fieldValue' => BackendUtility::getProcessedValue($table, $name, $metaData[$name], 0, false, false, (int)$metaData['uid']),
'fieldLabel' => htmlspecialchars($label),
];
}
}
}
}
Expand Down
Expand Up @@ -91,12 +91,12 @@ public function getMetaData(File $file)
$oEmbed = $this->getOEmbedData($this->getOnlineMediaId($file));

if (is_array($oEmbed) && $oEmbed !== []) {
$metadata['width'] = (int)$oEmbed['width'];
$metadata['height'] = (int)$oEmbed['height'];
$metadata['width'] = (int)($oEmbed['width'] ?? 0);
$metadata['height'] = (int)($oEmbed['height'] ?? 0);
if (empty($file->getProperty('title'))) {
$metadata['title'] = strip_tags($oEmbed['title']);
$metadata['title'] = strip_tags($oEmbed['title'] ?? '');
}
$metadata['author'] = $oEmbed['author_name'];
$metadata['author'] = $oEmbed['author_name'] ?? '';
}

return $metadata;
Expand Down

0 comments on commit 501b4f1

Please sign in to comment.