Skip to content

Commit

Permalink
[BUGFIX] Prevent undefined array key warning
Browse files Browse the repository at this point in the history
Fixes: Yoast#565
  • Loading branch information
peterkraume committed Dec 6, 2023
1 parent 77b5100 commit 9c6ee26
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Classes/Service/LinkingSuggestionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ protected function groupWordsByRecord(array $candidateWords): array
$candidateWordsByRecords = [];
foreach ($candidateWords as $candidateWord) {
$recordKey = $candidateWord['uid_foreign'] . '-' . $candidateWord['tablenames'];
if (!array_key_exists('weight', $candidateWord) || !array_key_exists('df', $candidateWord)) {
continue;
}
$candidateWordsByRecords[$recordKey][$candidateWord['stem']] = [
'weight' => (int)$candidateWord['weight'],
'df' => (int)$candidateWord['df']
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' => array_key_exists('tx_yoastseo_cornerstone', $data) ? (int)$data['tx_yoastseo_cornerstone'] : 0,
'score' => $score,
'active' => isset($currentLinks[$record])
];
Expand Down

0 comments on commit 9c6ee26

Please sign in to comment.