Browse Source

fix slug bug

gitcitadel
Silberengel 2 weeks ago
parent
commit
5d276d1f98
  1. 9
      src/Service/MagazineContentService.php
  2. 2
      src/Service/TopicIndexService.php

9
src/Service/MagazineContentService.php

@ -702,6 +702,7 @@ final class MagazineContentService
*/ */
public function collectFeaturedArticleSlugsForHome(array $categoryATags): array public function collectFeaturedArticleSlugsForHome(array $categoryATags): array
{ {
$seen = [];
$out = []; $out = [];
foreach ($categoryATags as $row) { foreach ($categoryATags as $row) {
$coord = $row[1]; $coord = $row[1];
@ -711,14 +712,16 @@ final class MagazineContentService
foreach ($this->buildFeaturedWallBlocksForCategoryTree($coord) as $b) { foreach ($this->buildFeaturedWallBlocksForCategoryTree($coord) as $b) {
foreach ($b['cards'] as $card) { foreach ($b['cards'] as $card) {
$s = \trim((string) $card->getSlug()); $s = \trim((string) $card->getSlug());
if ($s !== '') { if ($s !== '' && !isset($seen[$s])) {
$out[$s] = true; // Use a list, not slug-keyed map: PHP casts numeric-string keys to int.
$seen[$s] = true;
$out[] = $s;
} }
} }
} }
} }
return array_keys($out); return $out;
} }
/** /**

2
src/Service/TopicIndexService.php

@ -32,7 +32,7 @@ final class TopicIndexService
); );
$featured = []; $featured = [];
foreach ($slugs as $s) { foreach ($slugs as $s) {
$s = \strtolower(\trim($s)); $s = \strtolower(\trim((string) $s));
if ($s !== '') { if ($s !== '') {
$featured[$s] = true; $featured[$s] = true;
} }

Loading…
Cancel
Save