Skip to content

Fix: cache access token with cache()->put() for Laravel 12 compatibility#7

Merged
jplcodes merged 1 commit into
mainfrom
fix/l12-cache-put-token
May 29, 2026
Merged

Fix: cache access token with cache()->put() for Laravel 12 compatibility#7
jplcodes merged 1 commit into
mainfrom
fix/l12-cache-put-token

Conversation

@austinderrick
Copy link
Copy Markdown
Contributor

Summary

SigmaREST::_authenticate() cached the access token with the array-set form of the cache helper:

cache(['sigma_access_token' => $this->token], 60);

Under Laravel 12, that helper expands to app('cache')->put(key, value, ttl: $ttl) — a named ttl: argument. app('cache') is the CacheManager, which has no put() and forwards via __call($method, $parameters)$this->store()->$method(...$parameters). On stores whose put() signature doesn't name the parameter $ttl, PHP throws Error: Unknown named parameter $ttl (Illuminate/Cache/CacheManager.php). Laravel 9 passed the TTL positionally, so this only surfaces on 12.

Impact

Every Sigma REST authentication throws during token caching, so any consumer on Laravel 12 fails to connect to Sigma. Surfaced while upgrading Curator to Laravel 12 / Winter 1.3 (Curator PR #1535): the Sigma connection check never completes.

Fix

Use cache()->put('sigma_access_token', $this->token, 60) (positional TTL). This avoids the array-set/named-argument path entirely and works on Laravel 9 through 12. (Lines 99-100, which use cache()->has() / cache('key'), are already L12-safe.)

Verification

  • php -l clean.
  • On a Laravel 12 app (v12.61.0): cache()->put('sigma_access_token','x',60) returns true, whereas the old cache(['sigma_access_token'=>'x'],60) path throws Unknown named parameter $ttl in CI.

Once merged + tagged (e.g. 0.0.6), Curator bumps interworks/sigmarest to pick it up.

…ibility

_authenticate() cached the token with the array-set helper form cache(['sigma_access_token' => $token], 60).
Under Laravel 12 that helper calls app('cache')->put(key, value, ttl: $ttl) with a NAMED ttl argument;
CacheManager::__call forwards it via ...$parameters and throws 'Unknown named parameter $ttl' on stores
whose put() signature does not name the parameter $ttl. Use cache()->put('sigma_access_token', $token, 60)
(positional TTL), which works on Laravel 9-12. Fixes Sigma REST auth failing under the Curator L12 upgrade.
@jplcodes jplcodes merged commit f7a30b7 into main May 29, 2026
2 checks passed
@jplcodes jplcodes deleted the fix/l12-cache-put-token branch May 29, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants