Deprecated function: mb_substr(): Passing null to parameter #1

Created on 18 April 2024, 2 months ago
Updated 16 May 2024, about 1 month ago

I get this error on some view pages that use views_field_view:

Deprecated function: mb_substr(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Unicode::ucfirst() (line 234 of /core/lib/Drupal/Component/Utility/Unicode.php)
#0 /core/includes/bootstrap.inc(164): _drupal_error_handler_real()
#1 [internal function]: _drupal_error_handler()
#2 /core/lib/Drupal/Component/Utility/Unicode.php(234): mb_substr()
#3 /core/modules/views/src/Plugin/views/HandlerBase.php(252): Drupal\Component\Utility\Unicode::ucfirst()
#4 /core/modules/views/src/Plugin/views/argument/StringArgument.php(294): Drupal\views\Plugin\views\HandlerBase->caseTransform()
#5 /core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php(1039): Drupal\views\Plugin\views\argument\StringArgument->title()
#6 /modules/contrib/views_field_view/src/Plugin/views/field/View.php(326): Drupal\views\Plugin\views\argument\ArgumentPluginBase->getTitle()
#7 /modules/contrib/views_field_view/src/Plugin/views/field/View.php(231): Drupal\views_field_view\Plugin\views\field\View->getTokenValue()
#8 /core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1196): Drupal\views_field_view\Plugin\views\field\View->render()
#9 /core/modules/views/views.theme.inc(238): Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender()
#10 [internal function]: template_preprocess_views_view_field()
#11 /core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array()
#12 /core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render()
#13 /core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender()
#14 /core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1790): Drupal\Core\Render\Renderer->render()
#15 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(765): Drupal\views\Plugin\views\field\FieldPluginBase->theme()
#16 [internal function]: Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow()
#17 /core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array()
#18 /core/lib/Drupal/Core/Render/Renderer.php(859): Drupal\Core\Render\Renderer->doTrustedCallback()
#19 /core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback()
#20 /core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender()
#21 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(704): Drupal\Core\Render\Renderer->render()
#22 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(570): Drupal\views\Plugin\views\style\StylePluginBase->renderFields()
#23 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(461): Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping()
#24 /core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2183): Drupal\views\Plugin\views\style\StylePluginBase->render()
#25 /core/modules/views/src/ViewExecutable.php(1548): Drupal\views\Plugin\views\display\DisplayPluginBase->render()
#26 /core/modules/views/src/Plugin/views/display/Page.php(199): Drupal\views\ViewExecutable->render()
#27 /core/modules/views/src/ViewExecutable.php(1645): Drupal\views\Plugin\views\display\Page->execute()
#28 /core/modules/views/src/Element/View.php(81): Drupal\views\ViewExecutable->executeDisplay()
#29 [internal function]: Drupal\views\Element\View::preRenderViewElement()
#30 /core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array()
#31 /core/lib/Drupal/Core/Render/Renderer.php(859): Drupal\Core\Render\Renderer->doTrustedCallback()
#32 /core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback()
#33 /core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender()
#34 /core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender()
#35 /core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render()

I haven't tried -dev yet if it happens to be fixed there.

🐛 Bug report
Status

Active

Component

Miscellaneous

Created by

🇺🇸United States joshuasosa

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

Comments & Activities

  • Issue created by @joshuasosa
  • Assigned to adityarawat_ln
  • Issue was unassigned.
  • Assigned to Rajan Kumar@2026
  • Issue was unassigned.
  • 🇮🇳India adarshv

    Hello @joshuasosa, I've installed the module but haven't been able to reproduce the error. Could you please provide more detailed steps on how to reproduce it?

  • 🇺🇸United States joshuasosa

    The way I was able to reproduce the error is related to views contextual filters being fed into views_field_view. There could be other ways to instigate the error, but these steps are based on my real-world case.

    1. Create a content type and add a select list field to it with some options (e.g., Season with options Spring, Summer, Fall, Winter). It could also be set up as something else, like taxonomy or entity reference, just something to use as a 'category'.
    2. Create a view with the new content type using fields with a page using a path like /test/% and a block.
    3. Have the Title field shown on both displays just to show something.
    4. Add a contextual filter for the list field (e.g., Season) on both displays with a default to display all results.
    5. On the page display, set the list field's contextual filter to Case: Capitalize first letter. This could also be set to the other options.
    6. On the page display, add a view field view (i.e., Global: View) field.
    7. In the view field, set the view to the current view and the display to the other block in this view.
    8. Set the contextual filters to the arguments.list field that comes from the page (e.g., {{ arguments.field_list_value }} )
    6. Save and update the preview. The error log shows the error every time you update preview.

    The error can go away if we set the page's contextual filter to not alter the case or if we remove the page's views field view. But neither workaround is ideal.

    Using raw_arguments generates another series of views_field_view related errors:

    Warning: Undefined array key 0 in Drupal\views_field_view\Plugin\views\field\View->getTokenValue() (line 318 of /modules/contrib/views_field_view/src/Plugin/views/field/View.php)
    #0 /core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/w...', 318)
    #1 /modules/contrib/views_field_view/src/Plugin/views/field/View.php(318): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/w...', 318)
    #2 /modules/contrib/views_field_view/src/Plugin/views/field/View.php(231): Drupal\views_field_view\Plugin\views\field\View->getTokenValue('{{ raw_argument...', Object(Drupal\views\ResultRow), Object(Drupal\views\ViewExecutable))
    #3 /core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1196): Drupal\views_field_view\Plugin\views\field\View->render(Object(Drupal\views\ResultRow))
    #4 /core/modules/views/views.theme.inc(238): Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object(Drupal\views\ResultRow))
    #5 [internal function]: template_preprocess_views_view_field(Array, 'views_view_fiel...', Array)
    #6 /core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array('template_prepro...', Array)
    #7 /core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('views_view_fiel...', Array)
    #8 /core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
    #9 /core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1790): Drupal\Core\Render\Renderer->render(Array)
    #10 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(765): Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object(Drupal\views\ResultRow))
    #11 [internal function]: Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
    #12 /core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array)
    #13 /core/lib/Drupal/Core/Render/Renderer.php(859): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
    #14 /core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
    #15 /core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, true)
    #16 /core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render(Array, true)
    #17 /core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    #18 /core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #19 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(707): Drupal\Core\Render\Renderer->renderPlain(Array)
    #20 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(570): Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array)
    #21 /core/modules/views/src/Plugin/views/style/StylePluginBase.php(461): Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, true)
    #22 /core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2174): Drupal\views\Plugin\views\style\StylePluginBase->render()
    #23 /core/modules/views/src/ViewExecutable.php(1548): Drupal\views\Plugin\views\display\DisplayPluginBase->render()
    #24 /core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2464): Drupal\views\ViewExecutable->render()
    #25 /core/modules/views/src/ViewExecutable.php(1677): Drupal\views\Plugin\views\display\DisplayPluginBase->preview()
    #26 /core/modules/views_ui/src/ViewUI.php(612): Drupal\views\ViewExecutable->preview('page_1', Array)
    #27 /core/modules/views_ui/src/ViewPreviewForm.php(62): Drupal\views_ui\ViewUI->renderPreview('page_1', Array)
    #28 /core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\views_ui\ViewPreviewForm->form(Array, Object(Drupal\Core\Form\FormState))
    #29 /core/modules/views_ui/src/ViewFormBase.php(41): Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
    #30 [internal function]: Drupal\views_ui\ViewFormBase->buildForm(Array, Object(Drupal\Core\Form\FormState), 'page_1')
    #31 /core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
    #32 /core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm('view_preview_fo...', Object(Drupal\Core\Form\FormState))
    #33 /core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm('view_preview_fo...', Object(Drupal\Core\Form\FormState), Array)
    #34 /core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('view_preview_fo...', Array, Object(Drupal\Core\Form\FormState))
    #35 /core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\views_ui\ViewPreviewForm), Object(Drupal\Core\Form\FormState))
    #36 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
    #37 /core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #38 /core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #39 /core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #40 /core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #41 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #42 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #43 /core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #44 /core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #45 /core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #46 /core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #47 /core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #48 /core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #49 /core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #50 /core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #51 /core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #52 /core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #53 /core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #54 /index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #55 {main}

  • 🇺🇸United States joshuasosa

    Another temporary workaround is to not use the case transformation dropdown options in the contextual filter and instead use Twig to make adjustments when referring to the filter. For example, a contextual filter for seasons could override the view title and capitalize with something like {{ arguments.field_season_value|capitalize }}. (If needing to override view title with Twig filters, patch #7 in Change "Override title" field type from textfield to textarea Needs work can expand the maxlength.)

Production build 0.69.0 2024