Current state with latest updates

This commit is contained in:
2026-08-23 13:28:34 +02:00
parent 5af95f6533
commit f52879edbb
74 changed files with 5174 additions and 960 deletions
@@ -32,6 +32,7 @@ final class SitemapReleaseValidator
$errors = [];
$families = (array) ($manifest['families'] ?? []);
$groups = (array) ($manifest['groups'] ?? []);
$documents = (array) ($manifest['documents'] ?? []);
$rootContent = $this->releases->getDocument($releaseId, SitemapCacheService::INDEX_DOCUMENT);
@@ -41,10 +42,9 @@ final class SitemapReleaseValidator
$errors[] = 'Root sitemap.xml is missing or invalid.';
} else {
$rootLocs = $this->extractLocs($rootXml, 'sitemap');
$expectedRootLocs = array_map(
fn (string $entryName): string => url('/sitemaps/' . $entryName . '.xml'),
array_values(array_map(static fn (array $family): string => (string) ($family['entry_name'] ?? ''), $families)),
);
$expectedRoot = $this->build->buildIndex(true, false, array_keys($families));
$expectedRootXml = $this->loadXml((string) $expectedRoot['content']);
$expectedRootLocs = $expectedRootXml ? $this->extractLocs($expectedRootXml, 'sitemap') : [];
if ($rootLocs !== $expectedRootLocs) {
$errors[] = 'Root sitemap index does not match the manifest family entries.';
@@ -147,13 +147,48 @@ final class SitemapReleaseValidator
}
}
$groupReports = [];
foreach ($groups as $groupName => $group) {
$groupErrors = [];
$documentName = (string) ($group['entry_name'] ?? $groupName);
$artifact = $this->releases->getDocument($releaseId, $documentName);
if (! is_string($artifact) || $artifact === '') {
$groupErrors[] = 'Missing artifact [' . $documentName . '].';
} else {
$artifactXml = $this->loadXml($artifact);
$expected = $this->build->buildNamed($documentName, true, false);
$expectedXml = $expected !== null ? $this->loadXml((string) $expected['content']) : null;
if ($artifactXml === null || $expectedXml === null) {
$groupErrors[] = 'Invalid XML in group artifact [' . $documentName . '].';
} elseif ($this->extractLocs($artifactXml, 'sitemap') !== $this->extractLocs($expectedXml, 'sitemap')) {
$groupErrors[] = 'Group index artifact [' . $documentName . '] does not match expected sitemap references.';
}
}
$groupReports[] = [
'group' => $groupName,
'documents' => count((array) ($group['documents'] ?? [])),
'url_count' => (int) ($group['url_count'] ?? 0),
'errors' => $groupErrors,
];
foreach ($groupErrors as $groupError) {
$errors[] = $groupName . ': ' . $groupError;
}
}
return [
'ok' => $errors === [],
'release_id' => $releaseId,
'errors' => $errors,
'families' => $reports,
'groups' => $groupReports,
'totals' => [
'families' => count($families),
'groups' => count($groups),
'documents' => count($documents),
'urls' => array_sum(array_map(static fn (array $family): int => (int) ($family['url_count'] ?? 0), $families)),
'shards' => array_sum(array_map(static fn (array $family): int => (int) ($family['shard_count'] ?? 0), $families)),
@@ -255,4 +290,4 @@ final class SitemapReleaseValidator
return null;
}
}
}