Skip to content

Commit eb05041

Browse files
[6.x] Fix TypeError when elevated_session_duration is a string (#14771)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent cb75f5a commit eb05041

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/Providers/AppServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ private function registerElevatedSessionMacros()
357357
}
358358

359359
return Carbon::createFromTimestamp($lastElevated)
360-
->addMinutes(config('statamic.users.elevated_session_duration', 15))
360+
->addMinutes((float) config('statamic.users.elevated_session_duration', 15))
361361
->timestamp;
362362
});
363363

tests/Auth/ElevatedSessionTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ public function it_can_get_status_of_elevated_session()
7676
]);
7777
}
7878

79+
/**
80+
* @see https://github.com/statamic/cms/pull/14771
81+
**/
82+
#[Test]
83+
public function it_handles_string_config_value_for_elevated_session_duration()
84+
{
85+
config(['statamic.users.elevated_session_duration' => '15.5']);
86+
87+
$this
88+
->withElevatedSession(now()->subMinutes(5))
89+
->actingAs($this->user)
90+
->get('/cp/elevated-session')
91+
->assertOk()
92+
->assertJson([
93+
'elevated' => true,
94+
'expiry' => now()->addMinutes(10.5)->timestamp,
95+
'method' => 'password_confirmation',
96+
]);
97+
}
98+
7999
#[Test]
80100
public function it_can_get_status_of_elevated_session_when_session_key_does_not_exist()
81101
{

0 commit comments

Comments
 (0)