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

Disable caching of the default value if configured that way #40

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

rawilk
Copy link
Owner

@rawilk rawilk commented Oct 7, 2023

An issue was brought up in issue #39 where it can be confusing that the default value passed into settings()->get() is cached and not documented - see #39 (comment). This PR adds a cache_default_value configuration option. When set to false, the package will not cache the value of the default value passed in. The following code will work as expected with this new configuration option set to false.

$language = settings()->get('site.lang', 'en'); // 'en'

// some other code

// `site.lang` is still not persisted at this point, so the
//  default value we provide the function should be the value returned.
$language = settings()->get('site.lang', 'es'); // 'es'

This configuration option will be set to true by default, however in future major versions, it may default to false.

@rawilk rawilk added bug Something isn't working enhancement New feature or request labels Oct 7, 2023
@rawilk rawilk merged commit beb2e82 into main Oct 7, 2023
9 checks passed
@rawilk rawilk deleted the bug/default-valeu branch October 7, 2023 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant