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] Prevent undefined array key warning #566

Merged
merged 2 commits into from
Dec 18, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ We will follow [Semantic Versioning](http://semver.org/).

## UNRELEASED
### Fixed
- Prevent undefined array key warning within `LinkingSuggestionsService`
- Missing label of the tx_yoastseo_prominent_word table
- Removed exclude=true from tx_yoastseo_prominent_word fields, table already has hideTable
- Use `websiteTitle` of site configuration within snippet preview, previously this was only taken from site languages instead of the site itself
Expand Down
5 changes: 4 additions & 1 deletion Classes/Service/LinkingSuggestionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ protected function groupWordsByRecord(array $candidateWords): array
{
$candidateWordsByRecords = [];
foreach ($candidateWords as $candidateWord) {
if (!isset($candidateWord['weight'], $candidateWord['df'])) {
continue;
}
$recordKey = $candidateWord['uid_foreign'] . '-' . $candidateWord['tablenames'];
$candidateWordsByRecords[$recordKey][$candidateWord['stem']] = [
'weight' => (int)$candidateWord['weight'],
Expand Down Expand Up @@ -345,7 +348,7 @@ protected function linkRecords(array $scores, array $currentLinks): array
'recordType' => $this->getRecordType($table),
'id' => $uid,
'table' => $table,
'cornerstone' => (int)$data['tx_yoastseo_cornerstone'],
'cornerstone' => (int)($data['tx_yoastseo_cornerstone'] ?? 0),
'score' => $score,
'active' => isset($currentLinks[$record])
];
Expand Down