Skip to content

Commit

Permalink
TemplateMetadata::loadMetadata(): do not try to fetch reverse links f…
Browse files Browse the repository at this point in the history
…rom literal values
  • Loading branch information
zozlak committed Mar 22, 2024
1 parent 0da2273 commit 485a74d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/acdhOeaw/arche/oaipmh/metadata/TemplateMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ private function loadMetadata(array $resources,
TermInterface | null $predicate,
bool $inverse, bool $recursive): void {
$repo = $this->res->getRepo();
$baseUrlLen = strlen($repo->getBaseUrl());
$baseUrl = $repo->getBaseUrl();
$baseUrlLen = strlen($baseUrl);
$query = match (($recursive ? 'r' : '') . ($inverse ? 'i' : '')) {
'ri' => "
WITH t AS (SELECT * FROM get_relatives(?, ?, 999999, 0))
Expand All @@ -487,7 +488,8 @@ private function loadMetadata(array $resources,

if ($inverse) {
$loaded = self::$loadedInverse[(string) $predicate] ?? new SplObjectStorage();
$resources = array_filter($resources, fn($x) => !$loaded->contains($x));
// if resource IRI doesn't start with $baseUrl, then it's a literal on an already read subject and there is nothing to load
$resources = array_filter($resources, fn($x) => !$loaded->contains($x) && str_starts_with($x, $baseUrl));
foreach ($resources as $i) {
$loaded->attach($i);
}
Expand Down

0 comments on commit 485a74d

Please sign in to comment.