Deprecated function errors with Colorbox 2.1.1

Created on 11 October 2024, 7 months ago

We still see deprecated function errors on pages with images displayed with Colorbox 2.1.1 and PHP 8.1.18. It seems like the fix from #3355723 doesn't solve this issue.

Steps to reproduce

  1. This occurs when any of the images doesn't have alternative text. Adding alternative text for the images eliminates the error.
  2. Also, the error only happens when the page is not cached (error is not triggered after the page is served from cache).
Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Unicode::validateUtf8() (line 395 of core/lib/Drupal/Component/Utility/Unicode.php).
Drupal\Component\Utility\Unicode::validateUtf8(NULL) (Line: 65)
Drupal\Component\Utility\Xss::filter(NULL) (Line: 432)
_colorbox_formatter_get_caption(Array) (Line: 140)
template_preprocess_colorbox_formatter(Array, 'colorbox_formatter', Array)
call_user_func_array('template_preprocess_colorbox_formatter', Array) (Line: 261)
Drupal\Core\Theme\ThemeManager->render('colorbox_formatter', Array) (Line: 491)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array) (Line: 974)
Drupal\views\Plugin\views\field\EntityField->render_item(0, Array) (Line: 1214)
Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 238)
template_preprocess_views_view_field(Array, 'views_view_field', Array)
call_user_func_array('template_preprocess_views_view_field', Array) (Line: 261)
Drupal\Core\Theme\ThemeManager->render('views_view_field', Array) (Line: 491)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array) (Line: 1796)
Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object) (Line: 767)
Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
call_user_func_array(Array, Array) (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 870)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 432)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array) (Line: 706)
Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array) (Line: 572)
Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array) (Line: 84)
Drupal\blazy\Plugin\views\style\BlazyViews->render() (Line: 2177)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1592)
Drupal\views\ViewExecutable->render() (Line: 394)
Drupal\eva\Plugin\views\display\Eva->execute() (Line: 1689)
Drupal\views\ViewExecutable->executeDisplay('entity_view_1', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array) (Line: 115)
eva_entity_view(Array, Object, Object, 'full')
call_user_func_array(Object, Array) (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'eva') (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_view', Object) (Line: 423)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_view', Array) (Line: 289)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func_array(Array, Array) (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 870)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 432)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
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: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 191)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 128)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 82)
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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States sclsweb

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

Comments & Activities

  • Issue created by @sclsweb
  • πŸ‡ΊπŸ‡ΈUnited States paulmckibben Atlanta, GA

    Hi @scslweb, thanks for the report.

    I'm unable to reproduce this issue with empty alt text passing a NULL to Xss::filter(). When I have empty alt text, the string "" is passed as designed.

    Can you provide a set of steps to reproduce this issue on a clean Drupal install?

    Thanks!

Production build 0.71.5 2024