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

FIX Don't make queries if no custom config is set #11591

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

lekoala
Copy link
Contributor

@lekoala lekoala commented Jan 31, 2025

Description

Fixes unecessary queries, see issue for context

Manual testing steps

Check that no extra query is made on a fresh install

Issues

#11590

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@GuySartorelli
Copy link
Member

Note that this isn't really fixing a bug, but since it's a small change with very minimal risk I'll allow it to go in as a patch.

Comment on lines +1711 to +1713
if ($editorConfigCount === 0) {
return 'cms';
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we default to "cms" in this scenario? If there's no available config maps what would we expect returning "cms" to do here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because that's the current default if no value is found ?
this method always return something, "cms" being the default.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the default defined somewhere? A config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's hardcoded currently

return $currentName ? $currentName : 'cms';

i kept it the way it was :-)

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense - that part of code was hidden in the diff and I didn't think to expand to see further down.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for submitting this. Nice tidy enhancement.

if ($editorConfigCount === 1) {
return key($editorConfigMap);
}

foreach ($this->Groups() as $group) {
Copy link
Member

Choose a reason for hiding this comment

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

If we really wanted to be fancy, we could add a filter here `$this->Groups()->filter(['HtmlEditorConfig:not' => null]) - but the benefit of that would be super low so not worth holding up merging just for that. If you're keen on that I'd be happen to merge a separate PR for that change on its own.

@GuySartorelli GuySartorelli merged commit dac6b9e into silverstripe:5.3 Feb 4, 2025
17 checks passed
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.

3 participants