From 0cb9f33352cb4c96ff74a4ca1ff68422fcb8bd3d Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Wed, 1 Jun 2022 09:31:23 +0800 Subject: [PATCH] Finish fix --- system/Common.php | 6 ++++-- tests/system/CommonFunctionsTest.php | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/system/Common.php b/system/Common.php index e78f7c6ad7f1..6eeb55a3b784 100644 --- a/system/Common.php +++ b/system/Common.php @@ -1015,11 +1015,13 @@ function slash_item(string $item): ?string { $config = config(App::class); + $configItem = ''; + if (property_exists($config, $item)) { - $configItem = $config->{$item}; + $configItem = (string) $config->{$item}; } - if (! isset($configItem) || empty(trim($configItem))) { + if (trim($configItem) === '') { return null; } diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 3dd8cfe3cfe8..cdf9a8af7a9d 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -390,9 +390,9 @@ public function testReallyWritable() public function testSlashItem() { - $this->assertSame('/', slash_item('cookiePath')); // slash already there - $this->assertNull(null, slash_item('cookieDomain')); // empty, so untouched - $this->assertSame('en/', slash_item('defaultLocale')); // slash appended + $this->assertSame('/', slash_item('cookiePath')); + $this->assertNull(slash_item('cookieDomain')); + $this->assertSame('en/', slash_item('defaultLocale')); } protected function injectSessionMock()