Skip to content

Commit 975651f

Browse files
authored
[12.x] Fix using null cache store triggering PHP 8.5 deprecation (#58074)
* Ensure null driver uses string null name in CacheManager * Simplify logic in CacheManager now name is never null
1 parent 0a24afd commit 975651f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/Illuminate/Cache/CacheManager.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct($app)
5757
*/
5858
public function store($name = null)
5959
{
60-
$name = $name ?: $this->getDefaultDriver();
60+
$name = $name ?? $this->getDefaultDriver();
6161

6262
return $this->stores[$name] ??= $this->resolve($name);
6363
}
@@ -81,7 +81,7 @@ public function driver($driver = null)
8181
*/
8282
public function memo($driver = null)
8383
{
84-
$driver = $driver ?: $this->getDefaultDriver();
84+
$driver = $driver ?? $this->getDefaultDriver();
8585

8686
$bindingKey = "cache.__memoized:{$driver}";
8787

@@ -430,11 +430,9 @@ protected function getPrefix(array $config)
430430
*/
431431
protected function getConfig($name)
432432
{
433-
if (! is_null($name) && $name !== 'null') {
434-
return $this->app['config']["cache.stores.{$name}"];
435-
}
436-
437-
return ['driver' => 'null'];
433+
return $name !== 'null'
434+
? $this->app['config']["cache.stores.{$name}"]
435+
: ['driver' => 'null'];
438436
}
439437

440438
/**
@@ -444,7 +442,7 @@ protected function getConfig($name)
444442
*/
445443
public function getDefaultDriver()
446444
{
447-
return $this->app['config']['cache.default'];
445+
return $this->app['config']['cache.default'] ?? 'null';
448446
}
449447

450448
/**

0 commit comments

Comments
 (0)