PageHeaderSubscriber crashes on config import
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3537367. --> Reported by: [joachim](https://www.drupal.org/user/107701) Related to !28 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>I'm getting this on a `drush cim` -- not sure what the circumstances are, as previously it's worked fine.</p> <blockquote><p> TypeError: str_contains(): Argument #1 ($haystack) must be of type string, null given in str_contains() (line 58 of /app/web/modules/contrib/localgov_waste_collection/src/EventSubscriber/PageHeaderSubscriber.php).<br> [error] TypeError: str_contains(): Argument #1 ($haystack) must be of type string, null given in str_contains() (line 58 of /app/web/modules/contrib/localgov_waste_collection/src/EventSubscriber/PageHeaderSubscriber.php) #0 /app/web/modules/contrib/localgov_waste_collection/src/EventSubscriber/PageHeaderSubscriber.php(58): str_contains(NULL, 'localgov_waste_...')<br> #1 [internal function]: Drupal\localgov_waste_collection\EventSubscriber\PageHeaderSubscriber-&gt;setPageHeader(Object(Drupal\localgov_core\Event\PageHeaderDisplayEvent), 'localgov_core.p...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))<br> #2 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\localgov_core\Event\PageHeaderDisplayEvent), 'localgov_core.p...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))<br> #3 /app/web/modules/contrib/localgov_core/src/Plugin/Block/PageHeaderBlock.php(159): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch(Object(Drupal\localgov_core\Event\PageHeaderDisplayEvent), 'localgov_core.p...')<br> #4 /app/web/modules/contrib/localgov_core/src/Plugin/Block/PageHeaderBlock.php(104): Drupal\localgov_core\Plugin\Block\PageHeaderBlock-&gt;__construct(Array, 'localgov_page_h...', Array, Object(Drupal\Core\Routing\CurrentRouteMatch), Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher), Object(Symfony\Component\HttpFoundation\RequestStack), Object(Drupal\Core\Controller\TitleResolver))<br> #5 /app/web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21): Drupal\localgov_core\Plugin\Block\PageHeaderBlock::create(Object(Drupal\Core\DependencyInjection\Container), Array, 'localgov_page_h...', Array)<br> #6 /app/web/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(76): Drupal\Core\Plugin\Factory\ContainerFactory-&gt;createInstance('localgov_page_h...', Array)<br> #7 /app/web/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php(62): Drupal\Component\Plugin\PluginManagerBase-&gt;createInstance('localgov_page_h...', Array)<br> #8 /app/web/core/modules/block/src/BlockPluginCollection.php(57): Drupal\Core\Plugin\DefaultSingleLazyPluginCollection-&gt;initializePlugin('localgov_page_h...')<br> #9 /app/web/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php(80): Drupal\block\BlockPluginCollection-&gt;initializePlugin('localgov_page_h...')<br> #10 /app/web/core/modules/block/src/BlockPluginCollection.php(45): Drupal\Component\Plugin\LazyPluginCollection-&gt;get('localgov_page_h...')<br> #11 /app/web/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php(88): Drupal\block\BlockPluginCollection-&gt;get('localgov_page_h...')<br> #12 /app/web/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php(104): Drupal\Core\Plugin\DefaultSingleLazyPluginCollection-&gt;setConfiguration(Array)<br> #13 /app/web/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php(55): Drupal\Core\Plugin\DefaultSingleLazyPluginCollection-&gt;addInstanceId('localgov_page_h...', Array)<br> #14 /app/web/core/modules/block/src/BlockPluginCollection.php(34): Drupal\Core\Plugin\DefaultSingleLazyPluginCollection-&gt;__construct(Object(Drupal\Core\Block\BlockManager), 'localgov_page_h...', Array)<br> #15 /app/web/core/modules/block/src/Entity/Block.php(158): Drupal\block\BlockPluginCollection-&gt;__construct(Object(Drupal\Core\Block\BlockManager), 'localgov_page_h...', Array, 'gin_localgov_pa...')<br> #16 /app/web/core/modules/block/src/Entity/Block.php(168): Drupal\block\Entity\Block-&gt;getPluginCollection()<br> #17 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(301): Drupal\block\Entity\Block-&gt;getPluginCollections()<br> #18 /app/web/core/modules/block/src/Entity/Block.php(348): Drupal\Core\Config\Entity\ConfigEntityBase-&gt;preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))<br> #19 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(528): Drupal\block\Entity\Block-&gt;preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))<br> #20 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(483): Drupal\Core\Entity\EntityStorageBase-&gt;doPreSave(Object(Drupal\block\Entity\Block))<br> #21 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(257): Drupal\Core\Entity\EntityStorageBase-&gt;save(Object(Drupal\block\Entity\Block))<br> #22 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Config\Entity\ConfigEntityStorage-&gt;save(Object(Drupal\block\Entity\Block))<br> #23 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(617): Drupal\Core\Entity\EntityBase-&gt;save()<br> #24 /app/web/core/modules/block/block.module(144): Drupal\Core\Config\Entity\ConfigEntityBase-&gt;save()<br> #25 /app/web/core/modules/block/block.module(106): block_theme_initialize('gin')<br> #26 [internal function]: block_themes_installed(Array)<br> SNIP </p></blockquote> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Remove PageHeaderSubscriber completely, and put the text directly into the relevant form or page. It's not very good for performance to run a check on every single route.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <h3 id="summary-ui-changes">User interface changes</h3> <h3 id="summary-api-changes">API changes</h3> <h3 id="summary-data-model-changes">Data model changes</h3>
issue