-
Notifications
You must be signed in to change notification settings - Fork 395
Add default for ShardPreferences->showCheckboxes #5016
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -155,7 +155,7 @@ public function __construct(ConfigManagerInterface $configManager) | |||||
| $this->defaultSelectedShards = array_keys($this->shards); | ||||||
| } | ||||||
| // Apply checkbox visibility setting if applicable: | ||||||
| if (null !== ($visibleCheckboxes = $this->searchSettings['ShardPreferences']['showCheckboxes'])) { | ||||||
| if (null !== ($visibleCheckboxes = $this->searchSettings['ShardPreferences']['showCheckboxes'] ?? false)) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be null rather than false; this way, the setting overrides whatever property value is default in the class, rather than forcing a particular default value.
Suggested change
This was not a problem until #4353, which refactored the code to use arrays instead of config objects and accidentally omitted a fallback here. I'd suggest making this a bug fix PR targeted against the release-11.0 branch. If you have any trouble setting that up, please let me know and I'll be happy to help!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the fallback to null as suggested, but there's still a problem here, with the language in searches.ini Because those two lines, both specifying booleans, imply (IMHO) that you could declare
and get the default behavior. But you can't, because of This is perhaps made worse because of the bug (that no default was defined), so it's possible people have actually declared something like that. I can change the comment line to All that said, I'm being persnickety, and this is probably a larger question than this one setting.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maccabeelevine, I believe that the documentation remains accurate from the end-user's perspective. The setting is initialized to false in the property declaration. The config processing code says "only override the property's default with the value from the config if there IS a value in the config." If the user leaves the setting out, the setting will remain false; if the user sets the setting to false, we'll harmlessly overwrite the false with false. Even with the bug in place, I suspect that in non-strict mode, PHP will evaluate the expression to null, which will still get interpreted as false, so the setting always defaults to false. Am I missing/misunderstanding something?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Odd: when I click the link I placed above, my highlighted lines don't highlight correctly unless I open it in a new tab. Some new bit of GitHub weirdness.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In my testing, if the user sets the setting to false, the config is read as "" (empty string). (Is this another side effect of the Laminas config deprecation?) So then
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That has always been the behavior -- the ini parser returns truthy or falsey values, but they're not true Booleans. It would be wise to add type casting to make things more predictable, but functionally it doesn't make a difference in the current code. (It may begin to make more difference in future as we continue to get more strict about typing everything). |
||||||
| $this->visibleShardCheckboxes = $visibleCheckboxes; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And sorry, as I'm looking at this, maybe false is not good enough given
null !==. But that's what searches.ini claims...