Problem/Motivation
From the codebase:
if ($this->isForbidden() || $other->isForbidden()) {
// Removed for brevity, either or both are forbidden
}
elseif ($this->isAllowed() || $other->isAllowed()) {
// Removed for brevity, either or both are allowed
}
else {
// Removed for brevity, both have to be neutral at this point
// as we already checked for allowed and forbidden.
}
Yet in that final branch, we have the following check:
if (!$this->isNeutral() || ($this->getCacheMaxAge() === 0 && $other->isNeutral()) || ($this->getCacheMaxAge() !== 0 && $other instanceof CacheableDependencyInterface && $other->getCacheMaxAge() !== 0)) {
$merge_other = TRUE;
}
This can be simplified to:
if ($this->getCacheMaxAge() === 0 || ($other instanceof CacheableDependencyInterface && $other->getCacheMaxAge() !== 0)) {
$merge_other = TRUE;
}
Steps to reproduce
See code, read code, see bug.
Proposed resolution
See above.
Remaining tasks
Create MR with changes above.
User interface changes
/
API changes
/
Data model changes
/
Release notes snippet
/
Issue fork drupal-3451602
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 #3
kristiaanvandeneyndeComment #4
catchLooks like really straightforward clean-up to me. Original code just looks like it was written extremely defensively in case forbidden/allowed/neutral weren't the only three options but they are.
Comment #5
mxr576I agree, this a simple and clean optimization of the original solution. RTBC++
Comment #8
catchCommitted/pushed to 11.x and cherry-picked to 10.4.x, thanks!