Problem/Motivation
ContextualLinksHelper::addLinks() opens with:
public function addLinks(array &$renderElement, string $location, string $displayId, ?array $viewElement = NULL): void {
assert(in_array($location, ['block', 'page', 'view'], TRUE));But Drupal\views\Plugin\Block\ViewsExposedFilterBlock::build() calls into this path with the location 'exposed_filter':
// ViewsExposedFilterBlock::build()
$this->addContextualLinks($output, 'exposed_filter');
ViewsBlockBase::addContextualLinks() forwards that $block_type straight through to addLinks() as $location. With zend.assertions=1, this throws:
AssertionError: assert(in_array($location, ['block', 'page', 'view'], TRUE))
in assert() (line 79 of core/modules/views/src/ContextualLinksHelper.php).
Drupal\views\ContextualLinksHelper->addLinks()
Drupal\views\Plugin\Block\ViewsBlockBase->addContextualLinks()
Drupal\views\Plugin\Block\ViewsExposedFilterBlock->build()
Drupal\block\BlockViewBuilder::preRender()Steps to reproduce
- Install Drupal 11.4.x with the standard profile (assertions enabled — the default outside production, e.g. via development.services.yml / SymfonyRequirements).
- Enable the Views and Contextual Links modules.
- Create (or use) a view with an exposed filter and an "Exposed form in block" enabled, or use any view display that exposes its filters as a block.
- Place the view's "Exposed form: …" block in a visible region (e.g. Header) at Structure → Block layout.
- Visit any page where that block renders, as a user with permission to see contextual links (e.g. an admin).
- Result: AssertionError / WSOD on every page that renders the block.
- Expected: The page renders and the exposed-filter block shows its contextual links, as it did prior to 11.4.
Proposed resolution
Add 'exposed_filter' to the allowlist in the assertion so it matches the locations the method already supports:
assert(in_array($location, ['block', 'page', 'view', 'exposed_filter'], TRUE));
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3592878
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
quietone commentedHi, Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. This is also mentioned on the version section of the list of issue fields documentation. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.
Comment #4
phenaproximaThis works, and would fix Drupal CMS's CI pipeline (we currently have to patch around this).
Comment #5
phenaproximaComment #9
amateescu commentedI think this is a small bugfix that doesn't require test coverage (per #2972776: [policy, no patch] Better scoping for bug fix test coverage).
Committed and pushed 87c1c03df12 to main and ac253bb5976 to 11.x and c42c8879c0b to 11.4.x. Thanks!