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

Default settings values are not returned #3438

Closed
imorland opened this issue May 23, 2022 · 2 comments · Fixed by #3439
Closed

Default settings values are not returned #3438

imorland opened this issue May 23, 2022 · 2 comments · Fixed by #3439
Labels
Milestone

Comments

@imorland
Copy link
Member

Bug Report

Current Behavior
When calling $settings->get('some-key-that-is-not-already-in-the-database'), having already defined a default value in an extensions' extend.php, the value returned is null

Steps to Reproduce

  • In extend.php
new (Extend\Settings())
  ->default('some-key-that-is-not-already-in-the-database', 'my-default-value'),
  • Call that settings key
$settings->get('some-key-that-is-not-already-in-the-database')
  • Notice the value is null

Expected Behavior
The default value as defined in extend.php should be returned.

Environment

  • Flarum version: 1.3
  • Website URL: local
  • Webserver: n/a
  • Hosting environment: n/a
  • PHP version: 8.0.13
  • Browser: n/a

Additional Context
Add any other context about the problem here.

@davwheat
Copy link
Member

I noticed this too but assumed it was an issue with my local setup.

@SychO9
Copy link
Member

SychO9 commented May 23, 2022

I can reproduce this, which I find very confusing as the test still succeeds, I also remember testing this extender very well 🤔

allow me to investigate this.

public function custom_setting_default_prioritizes_extender()
{
$this->extend(
(new Extend\Settings())
->serializeToForum('customPrefix.unavailableCustomSetting3', 'custom-prefix.unavailable_custom_setting3')
->default('custom-prefix.unavailable_custom_setting3', 'extenderDefault')
);
$value = $this->app()
->getContainer()
->make('flarum.settings')
->get('custom-prefix.unavailable_custom_setting3', 'defaultParameterValue');
$this->assertEquals('extenderDefault', $value);
}

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

Successfully merging a pull request may close this issue.

3 participants