Skip to content

[6.x] Fix TypeError when elevated_session_duration is a string#14771

Merged
jasonvarga merged 6 commits into
6.xfrom
fix/elevated-session-string-duration
Jun 3, 2026
Merged

[6.x] Fix TypeError when elevated_session_duration is a string#14771
jasonvarga merged 6 commits into
6.xfrom
fix/elevated-session-string-duration

Conversation

@duncanmcclean
Copy link
Copy Markdown
Member

@duncanmcclean duncanmcclean commented Jun 3, 2026

This pull request fixes an issue where setting STATAMIC_ELEVATED_SESSION_DURATION via env() causes a TypeError.

This was happening because env() returns string values, and Carbon's addMinutes() method requires int|float. When a user publishes the config and modifies it to use env('STATAMIC_ELEVATED_SESSION_DURATION', 15), the string value like '15' would cause:

Carbon\Carbon::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given

This PR fixes it by casting the config value to float before passing it to addMinutes().

Fixes #14769

duncanmcclean and others added 3 commits June 3, 2026 10:22
This test reproduces GitHub issue #14769 where env() returns a string
value for STATAMIC_ELEVATED_SESSION_DURATION, causing Carbon's
addMinutes() to throw a TypeError.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Cast the config value to int before passing to Carbon's addMinutes(),
which requires int|float. This fixes the issue when users configure
the value via env() which returns strings.

Fixes #14769

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@michaldoda
Copy link
Copy Markdown

Thanks! just a quick suggestion: using float will help us avoid another error - Carbon allows float and int, so passing 1.5 will result in 1 in this case (int).

Copy link
Copy Markdown
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be a float

@duncanmcclean duncanmcclean requested a review from jasonvarga June 3, 2026 13:55
@jasonvarga jasonvarga merged commit eb05041 into 6.x Jun 3, 2026
19 checks passed
@jasonvarga jasonvarga deleted the fix/elevated-session-string-duration branch June 3, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cast 'statamic.users.elevated_session_duration' config value to float/integer

3 participants