Problem/Motivation
For PHP 8.1, calling the mb_strtolower() function with a null argument returns a deprecation error:
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in block_blacklist_block_alter() (line 16 of modules/contrib/block_blacklist/block_blacklist.module).
block_blacklist_block_alter(Array, NULL, NULL) (Line: 562)
Drupal\Core\Extension\ModuleHandler->alter('block', Array, NULL, NULL) (Line: 114)
Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler->alter('block', Array) (Line: 340)
Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions(Array) (Line: 295)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('matchtech_main_menu') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('matchtech_main_menu', Array) (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance('matchtech_main_menu', Array) (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin('matchtech_main_menu') (Line: 57)
Drupal\block\BlockPluginCollection->initializePlugin('matchtech_main_menu') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('matchtech_main_menu') (Line: 45)
Drupal\block\BlockPluginCollection->get('matchtech_main_menu') (Line: 83)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration(Array) (Line: 99)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId('matchtech_main_menu', Array) (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct(Object, 'matchtech_main_menu', Array) (Line: 34)
Drupal\block\BlockPluginCollection->__construct(Object, 'matchtech_main_menu', Array, 'mainmenu') (Line: 156)
Drupal\block\Entity\Block->getPluginCollection() (Line: 145)
Drupal\block\Entity\Block->getPlugin() (Line: 118)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 314)
Drupal\Core\Entity\EntityBase->access('view', NULL, 1) (Line: 63)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 274)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 42)
Drupal\force_password_change\Service\ForcePasswordChangeRedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 270)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in block_blacklist_block_alter() (line 17 of modules/contrib/block_blacklist/block_blacklist.module).
block_blacklist_block_alter(Array, NULL, NULL) (Line: 562)
Drupal\Core\Extension\ModuleHandler->alter('block', Array, NULL, NULL) (Line: 114)
Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler->alter('block', Array) (Line: 340)
Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions(Array) (Line: 295)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('matchtech_main_menu') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('matchtech_main_menu', Array) (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance('matchtech_main_menu', Array) (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin('matchtech_main_menu') (Line: 57)
Drupal\block\BlockPluginCollection->initializePlugin('matchtech_main_menu') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('matchtech_main_menu') (Line: 45)
Drupal\block\BlockPluginCollection->get('matchtech_main_menu') (Line: 83)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration(Array) (Line: 99)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId('matchtech_main_menu', Array) (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct(Object, 'matchtech_main_menu', Array) (Line: 34)
Drupal\block\BlockPluginCollection->__construct(Object, 'matchtech_main_menu', Array, 'mainmenu') (Line: 156)
Drupal\block\Entity\Block->getPluginCollection() (Line: 145)
Drupal\block\Entity\Block->getPlugin() (Line: 118)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 314)
Drupal\Core\Entity\EntityBase->access('view', NULL, 1) (Line: 63)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 274)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 42)
Drupal\force_password_change\Service\ForcePasswordChangeRedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 270)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in block_blacklist_block_alter() (line 18 of modules/contrib/block_blacklist/block_blacklist.module).
block_blacklist_block_alter(Array, NULL, NULL) (Line: 562)
Drupal\Core\Extension\ModuleHandler->alter('block', Array, NULL, NULL) (Line: 114)
Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler->alter('block', Array) (Line: 340)
Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions(Array) (Line: 295)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('matchtech_main_menu') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('matchtech_main_menu', Array) (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance('matchtech_main_menu', Array) (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin('matchtech_main_menu') (Line: 57)
Drupal\block\BlockPluginCollection->initializePlugin('matchtech_main_menu') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('matchtech_main_menu') (Line: 45)
Drupal\block\BlockPluginCollection->get('matchtech_main_menu') (Line: 83)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration(Array) (Line: 99)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId('matchtech_main_menu', Array) (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct(Object, 'matchtech_main_menu', Array) (Line: 34)
Drupal\block\BlockPluginCollection->__construct(Object, 'matchtech_main_menu', Array, 'mainmenu') (Line: 156)
Drupal\block\Entity\Block->getPluginCollection() (Line: 145)
Drupal\block\Entity\Block->getPlugin() (Line: 118)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 314)
Drupal\Core\Entity\EntityBase->access('view', NULL, 1) (Line: 63)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 274)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 42)
Drupal\force_password_change\Service\ForcePasswordChangeRedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 270)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Proposed resolution
Add checks without breaking interface of all logic to avoid cases when null gets into mbstr func.