From: Vincent Vanwaelscappel Date: Sat, 8 Apr 2023 10:55:00 +0000 (+0200) Subject: wip #5851 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=746b85337a50918977bf11f16586b2beedfa4ba3;p=cubist_cms-back.git wip #5851 --- diff --git a/src/app/CookieServiceProvider.php b/src/app/CookieServiceProvider.php index f35d554..1ecb689 100644 --- a/src/app/CookieServiceProvider.php +++ b/src/app/CookieServiceProvider.php @@ -10,13 +10,12 @@ class CookieServiceProvider extends Base public function register() { $this->app->singleton('cookie', function ($app) { - $config = $app->make('config')->get('session'); - - $domains = explode(',', $config['domain']); + $config = config('session'); + $domains = !is_null($config['domain']) ? explode(',', $config['domain']) : []; if (count($domains) === 1) { $domain = $domains[0]; - } else { + } else if (isset($_SERVER['HTTP_HOST'])) { foreach ($domains as $domain) { if (stripos($_SERVER['HTTP_HOST'], $domain) !== false) { $found = $domain; @@ -29,6 +28,10 @@ class CookieServiceProvider extends Base $domain = $found; } } + + if (!isset($domain)) { + $domain = count($domains) > 0 ? $domains[0] : null; + } config(['session.domain' => $domain]); return (new CookieJar)->setDefaultPathAndDomain( diff --git a/src/app/Magic/CubistMagicAttribute.php b/src/app/Magic/CubistMagicAttribute.php index 31d92a6..66423c3 100644 --- a/src/app/Magic/CubistMagicAttribute.php +++ b/src/app/Magic/CubistMagicAttribute.php @@ -57,7 +57,7 @@ trait CubistMagicAttribute return []; } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_null($offset)) { @@ -66,17 +66,17 @@ trait CubistMagicAttribute } } - public function offsetExists($offset) + public function offsetExists($offset): bool { return $this->hasAttribute($offset); } - public function offsetUnset($offset) + public function offsetUnset($offset): void { $this->unsetAttribute($offset); } - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->getAttribute($offset, null); }