Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast cache lifetime to integer by default #468

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

dwightwatson
Copy link
Contributor

This may be specific to my production environment (Heroku) but I can into this issue when upgrading to Laravel 11, specifically with Carbon 3. I have responsecache.cache_lifetime_in_seconds set in my production environment Laravel pulls it into the config as a string.

Carbon 3 blows up when passing a string to addSeconds here. Carbon 2 had no issues with accepting a string.

public function cacheRequestUntil(Request $request): DateTime
{
    return Carbon::now()->addSeconds(
        config('responsecache.cache_lifetime_in_seconds')
    );
}

Laravel 11 does include new config helpers to ensure you get a certain type (Config::integer() for example) but we can't use that here without dropping support for previous versions of Laravel.

I've made this change in my app already but thought it was worthwhile to propose to include by default as more applications will adopt Carbon 3 alongside Laravel 11 and this makes the configuration value explicit.

@freekmurze freekmurze merged commit e69b3f3 into spatie:main Apr 3, 2024
5 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants