Skip to content

Commit

Permalink
Fix possible null reference
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed Jan 15, 2025
1 parent 1e777c6 commit 07f8ce0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/LaunchDarkly/Impl/BigSegments/StoreManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@ public function getContextMembership(string $contextKey): ?Impl\BigSegments\Memb
return null;
}

$cachedItem = $this->config->cache?->getItem($contextKey);
$cachedItem = null;
try {
$cachedItem = $this->config->cache?->getItem($contextKey);
} catch (Exception $e) {
$this->logger->warning("Failed to retrieve cached item for big segment", ['contextKey' => $contextKey, 'exception' => $e->getMessage()]);
}
/** @var ?array */
$membership = $cachedItem?->get();

if ($membership === null) {
try {
$membership = $this->store->getMembership(StoreManager::hashForContextKey($contextKey));
if ($this->config->cache !== null) {
/**
* @psalm-suppress PossiblyNullArgument
*/
if ($this->config->cache !== null && $cachedItem !== null) {
$cachedItem->set($membership)->expiresAfter($this->config->contextCacheTime);

Check failure on line 59 in src/LaunchDarkly/Impl/BigSegments/StoreManager.php

View workflow job for this annotation

GitHub Actions / linux-build (8.1, true)

PossiblyNullArgument

src/LaunchDarkly/Impl/BigSegments/StoreManager.php:59:65: PossiblyNullArgument: Argument 1 of Psr\Cache\CacheItemInterface::expiresAfter cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 59 in src/LaunchDarkly/Impl/BigSegments/StoreManager.php

View workflow job for this annotation

GitHub Actions / linux-build (8.1, false)

PossiblyNullArgument

src/LaunchDarkly/Impl/BigSegments/StoreManager.php:59:65: PossiblyNullArgument: Argument 1 of Psr\Cache\CacheItemInterface::expiresAfter cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 59 in src/LaunchDarkly/Impl/BigSegments/StoreManager.php

View workflow job for this annotation

GitHub Actions / linux-build (8.2, true)

PossiblyNullArgument

src/LaunchDarkly/Impl/BigSegments/StoreManager.php:59:65: PossiblyNullArgument: Argument 1 of Psr\Cache\CacheItemInterface::expiresAfter cannot be null, possibly null value provided (see https://psalm.dev/078)

Check failure on line 59 in src/LaunchDarkly/Impl/BigSegments/StoreManager.php

View workflow job for this annotation

GitHub Actions / linux-build (8.2, false)

PossiblyNullArgument

src/LaunchDarkly/Impl/BigSegments/StoreManager.php:59:65: PossiblyNullArgument: Argument 1 of Psr\Cache\CacheItemInterface::expiresAfter cannot be null, possibly null value provided (see https://psalm.dev/078)

if (!$this->config->cache->save($cachedItem)) {
Expand Down

0 comments on commit 07f8ce0

Please sign in to comment.