Deprecated function: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Database\Connection->escapeLike()

Created on 7 June 2023, about 1 year ago
Updated 19 December 2023, 6 months ago

Problem/Motivation
This PHP warning started after upgrading to PHP to 8.1.19 on Centos 7
Using Flag 4.0@beta, and Drupal core 9.5.8

Related issue for Paragraph module is here

The warning is thrown on /node/add/page
Referrer /node/add/page

Deprecated function: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Database\Connection->escapeLike() (line 1525 of /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Database/Connection.php)
#0 /var/www/html/ehss_stage/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
#1 [internal function]: _drupal_error_handler()
#2 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Database/Connection.php(1525): addcslashes()
#3 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Database/Query/Select.php(431): Drupal\Core\Database\Connection->escapeLike()
#4 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(125): Drupal\Core\Database\Query\Select->escapeLike()
#5 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(70): Drupal\Core\Entity\Query\Sql\Condition::translateCondition()
#6 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(177): Drupal\Core\Entity\Query\Sql\Condition->compile()
#7 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(81): Drupal\Core\Entity\Query\Sql\Query->compile()
#8 /var/www/html/ehss_stage/web/modules/contrib/flag/src/FlagService.php(233): Drupal\Core\Entity\Query\Sql\Query->execute()
#9 /var/www/html/ehss_stage/web/modules/contrib/message_subscribe/message_subscribe_email/message_subscribe_email.module(24): Drupal\flag\FlagService->getAllEntityFlaggings()
#10 [internal function]: message_subscribe_email_flag_action_access()
#11 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array()
#12 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
#13 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#14 /var/www/html/ehss_stage/web/modules/contrib/flag/src/FlagType/FlagTypeBase.php(179): Drupal\Core\Extension\ModuleHandler->invokeAll()
#15 /var/www/html/ehss_stage/web/modules/contrib/flag/src/Plugin/Flag/EntityFlagType.php(315): Drupal\flag\FlagType\FlagTypeBase->actionAccess()
#16 /var/www/html/ehss_stage/web/modules/contrib/flag/src/Entity/Flag.php(343): Drupal\flag\Plugin\Flag\EntityFlagType->actionAccess()
#17 /var/www/html/ehss_stage/web/modules/contrib/flag/flag.module(150): Drupal\flag\Entity\Flag->actionAccess()
#18 [internal function]: {closure}()
#19 /var/www/html/ehss_stage/web/modules/contrib/flag/flag.module(155): array_filter()
#20 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(562): flag_form_alter()
#21 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Form/FormBuilder.php(838): Drupal\Core\Extension\ModuleHandler->alter()
#22 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Form/FormBuilder.php(282): Drupal\Core\Form\FormBuilder->prepareForm()
#23 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#24 /var/www/html/ehss_stage/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#25 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#26 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#27 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#28 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#29 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#30 /var/www/html/ehss_stage/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#31 /var/www/html/ehss_stage/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#32 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#33 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#34 /var/www/html/ehss_stage/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#35 /var/www/html/ehss_stage/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#36 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#37 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#38 /var/www/html/ehss_stage/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#39 /var/www/html/ehss_stage/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#40 /var/www/html/ehss_stage/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#41 {main}

🐛 Bug report
Status

Closed: works as designed

Component

Flag core

Created by

🇺🇸United States leisurman

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

Comments & Activities

  • Issue created by @leisurman
  • Assigned to samit.310@gmail.com
  • Status changed to Needs work about 1 year ago
  • Issue was unassigned.
  • Status changed to Postponed: needs info about 1 year ago
  • 🇮🇳India samit.310@gmail.com

    Hi @leisurman ,

    I checked it, but not able to reproduce it at my end, As per error tracing another contrib module message_subscribe is also there. Not sure but it might be because of it.

    #9 /var/www/html/ehss_stage/web/modules/contrib/message_subscribe/message_subscribe_email/message_subscribe_email.module(24): Drupal\flag\FlagService->getAllEntityFlaggings()

    Can you please share more detail steps to reproduce it?

    Thanks
    Samit K.

  • 🇩🇪Germany joooo_aah Bavaria

    Same here when creating new user (user has computed string field which sums up the flags). Variable $string is a big array/object

    TypeError: addcslashes(): Argument #1 ($string) must be of type string, Drupal\Core\Session\AccountProxy given in addcslashes() (line 1525 of core/lib/Drupal/Core/Database/Connection.php).

    addcslashes() (Line: 1525)
    Drupal\Core\Database\Connection->escapeLike() (Line: 431)
    Drupal\Core\Database\Query\Select->escapeLike() (Line: 125)
    Drupal\Core\Entity\Query\Sql\Condition::translateCondition() (Line: 70)
    Drupal\Core\Entity\Query\Sql\Condition->compile() (Line: 177)
    Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 81)
    Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 203)
    Drupal\flag\FlagService->getEntityFlaggings() (Line: 96)
    Drupal\flag\FlagService->getFlagging() (Line: 115)

    Using Flag 4.0@beta, and Drupal core 9.5.8

  • Status changed to Closed: works as designed 6 months ago
  • 🇨🇦Canada joel_osc

    Ran into this exact issue and it was as a result of the message_subscribe module... grabbing the latest dev version of it fixed the problem. This line here: #9 /var/www/html/ehss_stage/web/modules/contrib/message_subscribe/message_subscribe_email/message_subscribe_email.module(24): Drupal\flag\FlagService->getAllEntityFlaggings() in the stack trace indicates this as well. Basically the message_subscribe_email code was not checking whether or not the $flagging entity was complete before trying to get all flaggings, so on a new node you would get this error. The maintainers has since added a check for $flagging->id() before getAllEntityFlaggings() now which prevents the issue.

Production build 0.69.0 2024