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

Created on 6 July 2023, over 1 year ago
Updated 14 December 2023, about 1 year ago

Problem/Motivation

The following error started to show on the logs of my site:

Deprecated function: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\search_api_autocomplete\Utility\AutocompleteHelper->splitKeys() (line 41 of /mnt/www/html/mysite/docroot/modules/contrib/search_api_autocomplete/src/Utility/AutocompleteHelper.php)

#0 /mnt/www/html/mysite/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'ltrim(): Passin...', '/mnt/www/html/m...', 41)
#1 [internal function]: _drupal_error_handler(8192, 'ltrim(): Passin...', '/mnt/www/html/m...', 41)
#2 /mnt/www/html/mysite/docroot/modules/contrib/search_api_autocomplete/src/Utility/AutocompleteHelper.php(41): ltrim(NULL)
#3 /mnt/www/html/mysite/docroot/modules/contrib/search_api_autocomplete/src/Controller/AutocompleteController.php(90): Drupal\search_api_autocomplete\Utility\AutocompleteHelper->splitKeys(NULL)
#4 [internal function]: Drupal\search_api_autocomplete\Controller\AutocompleteController->autocomplete(Object(Drupal\search_api_autocomplete\Entity\Search), Object(Symfony\Component\HttpFoundation\Request))
#5 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#6 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#7 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#8 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#9 /mnt/www/html/mysite/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /mnt/www/html/mysite/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#11 /mnt/www/html/mysite/docroot/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(67): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /mnt/www/html/mysite/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /mnt/www/html/mysite/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /mnt/www/html/mysite/vendor/asm89/stack-cors/src/Asm89/Stack/Cors.php(49): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /mnt/www/html/mysite/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /mnt/www/html/mysite/docroot/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /mnt/www/html/mysite/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#22 {main}

Proposed resolution

Add a null-coalescing operator to set the $keys variable as an empty string

πŸ› Bug report
Status

Fixed

Version

1.0

Component

General code

Created by

πŸ‡²πŸ‡½Mexico GafgarionMorua Puerto Vallarta

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

Comments & Activities

Production build 0.71.5 2024