Fix: cache access token with cache()->put() for Laravel 12 compatibility#7
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SigmaREST::_authenticate()cached the access token with the array-set form of the cache helper:Under Laravel 12, that helper expands to
app('cache')->put(key, value, ttl: $ttl)— a namedttl:argument.app('cache')is theCacheManager, which has noput()and forwards via__call($method, $parameters)→$this->store()->$method(...$parameters). On stores whoseput()signature doesn't name the parameter$ttl, PHP throwsError: 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 usecache()->has()/cache('key'), are already L12-safe.)Verification
php -lclean.cache()->put('sigma_access_token','x',60)returnstrue, whereas the oldcache(['sigma_access_token'=>'x'],60)path throwsUnknown named parameter $ttlin CI.Once merged + tagged (e.g.
0.0.6), Curator bumpsinterworks/sigmarestto pick it up.