Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Added extra checks within the metatag generators in case fields do not exist, fixed hasSitemapFields method with correct property #553

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ We will follow [Semantic Versioning](http://semver.org/).
## UNRELEASED
### Fixed
- Show warning on linking suggestions when content element is set to "All Languages" instead of fatal exception
- Added extra checks within the metatag generators in case fields do not exist (opengraph, twitter, robots)
- `hasSitemapFields` now correctly returns the `sitemapFields` instead of `yoastSeoFields`

## 9.0.1 July 6, 2023
### Fixed
Expand Down
10 changes: 5 additions & 5 deletions Classes/MetaTag/AdvancedRobotsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function generate(array $params): void
$record = $params['page'];
}

$noImageIndex = (bool)$record['tx_yoastseo_robots_noimageindex'];
$noArchive = (bool)$record['tx_yoastseo_robots_noarchive'];
$noSnippet = (bool)$record['tx_yoastseo_robots_nosnippet'];
$noIndex = (bool)$record['no_index'];
$noFollow = (bool)$record['no_follow'];
$noImageIndex = (bool)($record['tx_yoastseo_robots_noimageindex'] ?? false);
$noArchive = (bool)($record['tx_yoastseo_robots_noarchive'] ?? false);
$noSnippet = (bool)($record['tx_yoastseo_robots_nosnippet'] ?? false);
$noIndex = (bool)($record['no_index'] ?? false);
$noFollow = (bool)($record['no_follow'] ?? false);

if ($noImageIndex || $noArchive || $noSnippet || $noIndex || $noFollow) {
$metaTagManagerRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);
Expand Down
2 changes: 1 addition & 1 deletion Classes/MetaTag/Generator/OpenGraphGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function generate(Record $record): void
$manager->addProperty('og:description', $ogDescription);
}

if ($record->getRecordData()['og_image']) {
if ($record->getRecordData()['og_image'] ?? false) {
$fileCollector = GeneralUtility::makeInstance(FileCollector::class);
$fileCollector->addFilesFromRelation($record->getTableName(), 'og_image', $record->getRecordData());
$manager = $this->managerRegistry->getManagerForProperty('og:image');
Expand Down
4 changes: 2 additions & 2 deletions Classes/MetaTag/Generator/TwitterGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public function generate(Record $record): void
$manager->addProperty('twitter:title', $twitterTitle);
}

$twitterDescription = $record->getRecordData()['twitter_description'];
$twitterDescription = $record->getRecordData()['twitter_description'] ?? '';
if (!empty($twitterDescription)) {
$manager = $this->managerRegistry->getManagerForProperty('twitter:description');
$manager->removeProperty('twitter:description');
$manager->addProperty('twitter:description', $twitterDescription);
}

if ($record->getRecordData()['twitter_image']) {
if ($record->getRecordData()['twitter_image'] ?? false) {
$fileCollector = GeneralUtility::makeInstance(FileCollector::class);
$fileCollector->addFilesFromRelation($record->getTableName(), 'twitter_image', $record->getRecordData());
$manager = $this->managerRegistry->getManagerForProperty('twitter:image');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Record/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function setYoastSeoFields(bool $yoastSeoFields): self

public function hasSitemapFields(): bool
{
return $this->yoastSeoFields;
return $this->sitemapFields;
}

public function setSitemapFields(bool $sitemapFields): self
Expand Down