Skip to content
Merged
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
14 changes: 9 additions & 5 deletions packages/icon/src/Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,20 @@ public function render(string $icon): ?string
return null;
}

$fetched = false;
$svg = $this->iconCache->resolve(
key: "icon-{$collection}-{$iconName}",
callback: fn () => $this->fetchSvg($collection, $iconName),
callback: function () use ($collection, $iconName, &$fetched) {
$fetched = true;

return $this->fetchSvg($collection, $iconName);
},
expiresAt: $this->iconConfig->expiresAfter,
);

/** @var bool $failed */
$failed = $this->iconCache->get("icon-failure-{$collection}-{$iconName}");

if ($failed) {
// fetchSvg() returns null only on failure, and resolve() will have cached
// that null — drop it so a retry can happen once the failure marker expires.
if ($fetched && $svg === null) {
$this->iconCache->delete("icon-{$collection}-{$iconName}");
}

Expand Down
Loading