Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The FlagServiceInterface::getFlags()
method is supposed to return an array of flags, keyed by entity id (in this case, flag machine name). When the user account is omitted, this holds true. However, when filtering for access, the flag ID keys are lost:
if ($account == NULL) {
return $flags;
}
$filtered_flags = [];
foreach ($flags as $flag) {
if ($flag->actionAccess('flag', $account)->isAllowed() ||
$flag->actionAccess('unflag', $account)->isAllowed()) {
$filtered_flags[] = $flag;
}
}
return $filtered_flags;
Proposed resolution
The $filtered_flags
array should retain the flag ID keying.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | 2827864-02.patch | 1.15 KB | jhedstrom |
#2 | 2827864-02-TEST-ONLY.patch | 624 bytes | jhedstrom |
Comments
Comment #2
jhedstromComment #6
joachim CreditAttribution: joachim commentedGood catch!