Assert failure in ChainedPlaceholderStrategy.php

Created on 28 June 2016, over 8 years ago
Updated 30 January 2023, almost 2 years ago

When working on a Drupal 8 website in my local environment, I'm getting the following warning on each page:

Error messageWarning: assert(): At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.: "!empty($this->placeholderStrategies)" failed in Drupal\Core\Render\Placeholder\ChainedPlaceholderStrategy->processPlaceholders() (line 43 of core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php).

The assertion in question is:

// Assert that there is at least one strategy.
    assert('!empty($this->placeholderStrategies)', 'At least one placeholder strategy must be present; by default the fallback strategy \Drupal\Core\Render\Placeholder\SingleFlushStrategy is always present.');

This assertion should not be failing, since the SingleFlushStrategy is actually present in the placeholderStrategies array. I'm guessing that the problem is that when assert executes the contents of the assertion string, it is outside of the context of the ChainedPlaceholderStrategy class, and therefore it doesn't have access to the protected $placeholderStrategies property.

A simple solution should be to remove the quotes, so empty() is called in the context of the class function where it has access to the protected variable and can evaluate it properly.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
RenderΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mikemccaffrey

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.71.5 2024