Problem/Motivation
The logic in OptionsHooks::hasValuesInUse() is unnecessarily nested. When no values are provided, no entity query is required, and the method can return early.
Steps to reproduce
Review core/modules/options/src/Hook/OptionsHooks.php and observe that the entity query and its result handling are nested inside an if ($values) condition.
Proposed resolution
Return FALSE early when $values is empty. Otherwise, execute the entity query and return its result cast to a boolean.
Remaining tasks
- Review the change.
- Confirm that existing automated tests pass.
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
Not required - no functional changes.
Issue fork drupal-3615750
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nicxvan commentedhttps://git.drupalcode.org/project/drupal/-/merge_requests/14683#note_16...
Comment #3
nicxvan commentedComment #7
kieran.cottUpdated the issue summary and implemented the change suggested in https://git.drupalcode.org/project/drupal/-/merge_requests/14683#note_16....
Comment #8
smustgrave commentedEarly return looks good to me.
Comment #9
nicxvan commentedIsn't it better to check if the array is empty? Or is the ! operator preferred?
Comment #10
kieran.cottempty()might be better as you suggest, now updated.Comment #11
nicxvan commentedThanks! Looks great.