hash(): Passing null to parameter #2 ($data) of type string is deprecated in generateFieldTableName

Created on 31 March 2022, about 2 years ago
Updated 1 February 2024, 5 months ago

Problem/Motivation

Having an error for Drupal 9.3.x under PHP 8.1
While installing module with custom storage fields

Proposed resolution

Not to pass any NULL value to the hash function in any config import case
Have ?? '' for all passed 2nd argument values into the hash function

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ➖ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ➖ Code review by maintainers
  • ➖ Full testing and approval
  • ➖ Credit contributors
  • ➖ Review with the product owner
  • ➖ Release notes snippet
  • ❌ Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
📌 Task
Status

Active

Version

11.0 🔥

Component
Other 

Last updated 15 minutes ago

Created by

🇯🇴Jordan Rajab Natshah Jordan

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

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.

  • 🇳🇿New Zealand jlscott

    I have just upgraded my Varbase system from 9.0.10 to 9.0.11, which uses Drupal core 9.5.2. That was fine, but on switching Php from 8.0 to 8.1 I get several instance of the error when viewing the status report.

    Deprecated function: hash(): Passing null to parameter #2 ($data) of type string is deprecated in Drupal\Core\Entity\Sql\DefaultTableMapping->generateFieldTableName() (line 632 of core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php).

    Drupal\Core\Entity\Sql\DefaultTableMapping->generateFieldTableName(Object, 1) (Line: 602)
    Drupal\Core\Entity\Sql\DefaultTableMapping->getDedicatedRevisionTableName(Object) (Line: 253)
    Drupal\Core\Entity\Sql\DefaultTableMapping::create(Object, Array, '') (Line: 381)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->getCustomTableMapping(Object, Array) (Line: 356)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->getTableMapping() (Line: 203)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->initTableLayout() (Line: 188)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->__construct(Object, Object, Object, Object, Object, Object, Object, Object) (Line: 156)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage::createInstance(Object, Object) (Line: 269)
    Drupal\Core\Entity\EntityTypeManager->createHandlerInstance('Drupal\Core\Entity\Sql\SqlContentEntityStorage', Object) (Line: 258)
    Drupal\Core\Entity\EntityTypeManager->getHandler('block_content', 'storage') (Line: 192)
    Drupal\Core\Entity\EntityTypeManager->getStorage('block_content') (Line: 323)
    Drupal\Core\Entity\EntityDefinitionUpdateManager->requiresEntityStorageSchemaChanges(Object, Object) (Line: 261)
    Drupal\Core\Entity\EntityDefinitionUpdateManager->getChangeList() (Line: 88)
    Drupal\Core\Entity\EntityDefinitionUpdateManager->getChangeSummary() (Line: 956)
    system_requirements('runtime')
    call_user_func_array(Object, Array) (Line: 426)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'system') (Line: 405)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('requirements', Object) (Line: 433)
    Drupal\Core\Extension\ModuleHandler->invokeAll('requirements', Array) (Line: 109)
    Drupal\system\SystemManager->listRequirements() (Line: 49)
    Drupal\system\Controller\SystemInfoController->status()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
    Symfony\Component\HttpKernel\HttpKernel->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: 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)

  • 🇯🇴Jordan Rajab Natshah Jordan

    Facing more issue
    🐛 Querying with NULL values results in warning mb_strtolower(): Passing null to parameter is deprecated Needs work

    When local and translation is enabled.
    Find out that the module Smart Trim still uses

     $dom = Html::load(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
    

    Deprecated function: mb_convert_encoding(): Passing null to parameter #1 ($string) of type array|string is deprecated

    Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\Component\Transliteration\PhpTransliteration->transliterate()

    Deprecated function: mb_convert_encoding(): Passing null to parameter #1 ($string) of type array|string is deprecated in Drupal\Component\Transliteration\PhpTransliteration->transliterate() (line 140 of /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php)
    #0 /var/www/html/dev/varbase9c1/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
    #1 [internal function]: _drupal_error_handler()
    #2 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php(140): mb_convert_encoding()
    #3 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Block/BlockPluginTrait.php(254): Drupal\Component\Transliteration\PhpTransliteration->transliterate()
    #4 /var/www/html/dev/varbase9c1/docroot/core/modules/block/src/BlockForm.php(405): Drupal\Core\Block\BlockBase->getMachineNameSuggestion()
    #5 /var/www/html/dev/varbase9c1/docroot/core/modules/block/src/BlockForm.php(136): Drupal\block\BlockForm->getUniqueMachineName()
    #6 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\block\BlockForm->form()
    #7 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
    #8 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array()
    #9 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(281): Drupal\Core\Form\FormBuilder->retrieveForm()
    #10 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm()
    #11 /var/www/html/dev/varbase9c1/docroot/core/modules/block/src/Controller/BlockAddController.php(27): Drupal\Core\Entity\EntityFormBuilder->getForm()
    #12 [internal function]: Drupal\block\Controller\BlockAddController->blockAddConfigureForm()
    #13 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #14 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #15 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
    #16 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #17 /var/www/html/dev/varbase9c1/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #18 /var/www/html/dev/varbase9c1/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #19 /var/www/html/dev/varbase9c1/docroot/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(68): Symfony\Component\HttpKernel\HttpKernel->handle()
    #20 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle()
    #21 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #22 /var/www/html/dev/varbase9c1/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #23 /var/www/html/dev/varbase9c1/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #24 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #25 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #26 /var/www/html/dev/varbase9c1/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #27 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle()
    #28 /var/www/html/dev/varbase9c1/docroot/index.php(19): Drupal\Core\DrupalKernel->handle()
    #29 {main}
    
    
    Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\Component\Transliteration\PhpTransliteration->transliterate() (line 133 of /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php)
    #0 /var/www/html/dev/varbase9c1/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
    #1 [internal function]: _drupal_error_handler()
    #2 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php(133): strpos()
    #3 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Block/BlockPluginTrait.php(254): Drupal\Component\Transliteration\PhpTransliteration->transliterate()
    #4 /var/www/html/dev/varbase9c1/docroot/core/modules/block/src/BlockForm.php(405): Drupal\Core\Block\BlockBase->getMachineNameSuggestion()
    #5 /var/www/html/dev/varbase9c1/docroot/core/modules/block/src/BlockForm.php(136): Drupal\block\BlockForm->getUniqueMachineName()
    #6 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\block\BlockForm->form()
    #7 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
    #8 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array()
    #9 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(281): Drupal\Core\Form\FormBuilder->retrieveForm()
    #10 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm()
    #11 /var/www/html/dev/varbase9c1/docroot/core/modules/block/src/Controller/BlockAddController.php(27): Drupal\Core\Entity\EntityFormBuilder->getForm()
    #12 [internal function]: Drupal\block\Controller\BlockAddController->blockAddConfigureForm()
    #13 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #14 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #15 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
    #16 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #17 /var/www/html/dev/varbase9c1/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #18 /var/www/html/dev/varbase9c1/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #19 /var/www/html/dev/varbase9c1/docroot/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(68): Symfony\Component\HttpKernel\HttpKernel->handle()
    #20 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle()
    #21 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #22 /var/www/html/dev/varbase9c1/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #23 /var/www/html/dev/varbase9c1/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #24 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #25 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #26 /var/www/html/dev/varbase9c1/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #27 /var/www/html/dev/varbase9c1/docroot/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle()
    #28 /var/www/html/dev/varbase9c1/docroot/index.php(19): Drupal\Core\DrupalKernel->handle()
    #29 {main}
    .
    
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    If getUniqueStorageIdentifier is empty - it looks like something else is seriously broken?

  • 🇯🇴Jordan Rajab Natshah Jordan

    #14
    🐛 Querying with NULL values results in warning mb_strtolower(): Passing null to parameter is deprecated Needs work

    You are right, Joris

    Reading again the comments

          // with table names longer than 64 characters, we hash the unique storage
          // identifier and return the first 10 characters so we end up with a short
          // unique ID.
    
          // up with table names longer than 64 characters, we hash the unique
          // storage identifier and return the first 10 characters so we end up with
          // a short unique ID.
    
          // Use a shorter separator and a hash of the field storage unique
          // identifier.
    

    It could be happening with entity configs or configs, which had no UUID or entity data.
    Then a UUID was added to the logic or config.

    Or the other way, It had a UUID and that UUID was removed from default configs or config schema or from the logic.

    As Lee said stack trace

    Tested with PHP 8.1 ..
    In PHP 8.2 many contrib modules are still hitting errors/warnings with mb_strtolower and other mb_str .... functions

  • I saw this error on a site that already has Drupal 10.2 installed. An anonymous user visited /core/install.php?profile=default

Production build 0.69.0 2024