Search module is not working properly

Created on 28 January 2023, almost 2 years ago
Updated 10 May 2023, over 1 year ago

Some time search fine and some time getting below error.
e.g: if I search about us and getting

htttps://www.example.com/search/node?keys=about us

TypeError: strip_tags(): Argument #1 ($string) must be of type string, array given in strip_tags() (line 1120 of /code/vendor/twig/twig/src/Extension/CoreExtension.php)

This is core issue in Drupal 9 and need to fixed quickly.

💬 Support request
Status

Fixed

Version

9.5

Component
Theme 

Last updated 18 minutes ago

Created by

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

Comments & Activities

  • Issue created by @pankaj1390
  • 🇬🇧United Kingdom longwave UK

    What theme are you using?

    Can you provide a full backtrace for the error?

  • I am using bootstrap barrio theme

    full backtrace for the error

    TypeError: strip_tags(): Argument #1 ($string) must be of type string, array given in strip_tags() (line 1120 of /code/vendor/twig/twig/src/Extension/CoreExtension.php)
    #0 /code/vendor/twig/twig/src/Extension/CoreExtension.php(1120): strip_tags(Array, NULL)
    #1 /tmp/rolling/live_13/twig/63d484a15a0d2_paragraph--section_six_ca_MsCeIVUMbWuwlCFVlmGB8oVEl/S-FIJS_7Jg3rOC5Tbnbp-uxqAp--unDy8P7d1QQng4U.php(111): twig_striptags(Array)
    #2 /code/vendor/twig/twig/src/Template.php(405): __TwigTemplate_d0fc208014a2658a4fa7261afad5c1554728b41a1b6ca7ca4e939db924a8feb2->doDisplay(Array, Array)
    #3 /code/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
    #4 /code/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
    #5 /code/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array)
    #6 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/inscopix...', Array)
    #7 /code/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('paragraph', Array)
    #8 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false)
    #9 /code/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array)
    #10 /tmp/rolling/live_13/twig/63d484a15a0d2_field.html.twig_0g0RGvrIcOEL0terb1vEN_PRN/REVYgcI37uj7KSrTlzMlMmitWcFLTinySvoC2COpuv0.php(67): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #11 /code/vendor/twig/twig/src/Template.php(405): __TwigTemplate_7fe1dbd914b036222150699fc1bc438b95bebc68a9386d62078211339b4472fc->doDisplay(Array, Array)
    #12 /code/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
    #13 /code/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
    #14 /code/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array)
    #15 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/contrib/...', Array)
    #16 /code/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('field', Array)
    #17 /code/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender(Array)
    #18 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, true)
    #19 /code/web/core/lib/Drupal/Core/Render/Renderer.php(160): Drupal\Core\Render\Renderer->render(Array, true)
    #20 /code/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    #21 /code/web/core/lib/Drupal/Core/Render/Renderer.php(161): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #22 /code/web/core/modules/node/src/Plugin/Search/NodeSearch.php(371): Drupal\Core\Render\Renderer->renderPlain(Array)
    #23 /code/web/core/modules/node/src/Plugin/Search/NodeSearch.php(242): Drupal\node\Plugin\Search\NodeSearch->prepareResults(Object(Drupal\Core\Database\StatementWrapper))
    #24 /code/web/core/modules/search/src/Plugin/SearchPluginBase.php(98): Drupal\node\Plugin\Search\NodeSearch->execute()
    #25 /code/web/core/modules/search/src/Controller/SearchController.php(102): Drupal\search\Plugin\SearchPluginBase->buildResults()
    #26 [internal function]: Drupal\search\Controller\SearchController->view(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\search\Entity\SearchPage))
    #27 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #28 /code/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #29 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #30 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #31 /code/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #32 /code/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #33 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #34 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #35 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #36 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #37 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #38 /code/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #39 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #40 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #41 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #42 /code/web/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #43 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #44 {main}

  • The theme file being rendered is something like themes/childtheme…. Is that a custom theme?

    Is this replicable with Olivero theme?

    What change precipitated this issue?

  • Yes @clifen this is a custom for privacy matter I user child theme and replica of Bootstrap barrio theme

    Search is not working properly few keyword getting searched but few gives error

  • Status changed to Postponed: needs info almost 2 years ago
  • That is already more information than we had. I don't know what you mean by a "replica" of a theme. Anyway, if you require urgent support you will have to be more forthcoming and answer all of our questions.

  • Theme is the custom theme

    name: themename
    type: theme
    description: 'Basic structure for a theme.'
    core: 8.x
    core_version_requirement: ^8 || ^9
    base theme: bootstrap_barrio

  • Please read again comment #4 and get those answers please. You assert this is an issue with Drupal Core but we have not yet determined that.

    Also, what is on line 111 of /tmp/rolling/live_13/twig/63d484a15a0d2_paragraph--section_six_ca_MsCeIVUMbWuwlCFVlmGB8oVEl/S-FIJS_7Jg3rOC5Tbnbp-uxqAp--unDy8P7d1QQng4U.php that is passing an array to the striptags filter?

  • The theme file being rendered is something like themes/childtheme…. Is that a custom theme?

    Ans. Yes this is a custom theme

    Is this replicable with Olivero theme?
    Ans. No

    What change precipitated this issue?
    Ans. After migrate Drupal 8 to Drupal 9

  • {%
    set classes = [
    'paragraph',
    'paragraph--type--' ~ paragraph.bundle|clean_class,
    view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
    ]
    %}
    
    <div class="view-header">
        <div class="headings fadeInUp wow">
            <h2> {{ content.field_title}}</h2>
            {% if content.field_description.0 is not empty %}
            <p>{{ content.field_description }}</p>
            {% endif %}
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-6 fadeInUp wow">
            <div class="parter-desc-block">
                <h3>{{ content.field_left_title }}</h3>
               
                <div class="parter-img-new">			
    				<img src="{{ file_url(paragraph.field_left_side_image_in_place_o.entity.uri.value) }}"/>
                </div>
                
            </div>
        </div>
        <div class="col-md-6 fadeInUp wow">
            <div class="parter-desc-block">
                <h3>{{ content.field_right_title }}</h3>
                <div class="owl-slider">
                    <div id="partner-slider" class="owl-carousel partner-slider">
                        {% if paragraph.field_carousel|length > 0 %}
                            {% for object in paragraph.field_carousel %}
                            <div class="item">
                                <div class="partner-slide-content">
                                    <p> {{ object.entity.field_description.value|striptags }}</p>
                                    <img src="{{ file_url(object.entity.field_about_image.entity.uri.value) }}" alt="{{ object.entity.field_about_image.alt }}" class="img-fluid">
                                    <h6>{{ object.entity.field_partner_name.value }}</h6>
                                </div>
                            </div>
                            {% endfor %}
                        {% endif %}                   
                    </div>
                </div>
            </div>
        </div>
    </div>
  • Something is passing an array to the striptags Twig filter. This is not a core bug but rather an issue with that custom theme.

  • I am using same theme in Drupal 8 and It is working fine. I am sure this is a core issue

  • Are those sites on the same version of PHP?

  • I see when I disabled search module and enable it worked fine

  • If this is php issue it should not worked after uninstall and enabled

  • 🇬🇧United Kingdom longwave UK

    The only use of striptags in that template is

    <p> {{ object.entity.field_description.value|striptags }}</p>
    

    So for some reason field_description.value appears to be an array and not a string. The next step would be figure out which entities cause the issue and find out what is different about them. These appear to be Paragraph entities, so this also could be an issue in the Paragraphs module.

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    You shouldn't be passing value to strip tags anyway, you should be using processed

    But perhaps you can fix this by adding |render before the strip tags

  • What is the role template in the search that I break the search?

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    The NodeSearch plugin renders the node in 'search result' view mode. That is ending up in your paragraph template

  • Status changed to Fixed over 1 year ago
  • There has been no activity here in months.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024