Automated list from Banner bottom components throws error

Created on 14 June 2024, 5 months ago
Updated 13 July 2024, 4 months ago

Problem

There is an issue with using the Automated list with the Banner bottom components. An error is thrown once the page has been saved and attempting to view the page.

Steps to reproduce

  1. Install locally GovCMS via https://github.com/govCMS/scaffold and configure site as SaaS. As of time of writing, the GovCMS version is 3.13.0 (Drupal version is 10.2.6) and scaffold is 3.3.0

  2. Manually add theme to themes folder in site

  3. Enable the required modules via drush drush pm:enable components inline_form_errors rest field_group layout_builder_restrictions linkit menu_block paragraphs redirect webform

  4. Install the theme, drush pm:enable civictheme noting outstanding issues with "The "civictheme_one_column" plugin does not exist" . Set theme as default drush theme:enable civictheme

  5. Clear site cache with drush cr

  6. Browse to Home of site to confirm theme is installed

  7. Browse to Appearance then Settings on CivicTheme 1.7.1

  8. Open Content provisioning. Retain all settings that are checked and click Provision content

  9. Run separate drush cr just in case :)

  10. Browse to Home of site confirm items have been provisioned

  11. Browse to Content > Add Content

  12. Select Page (this assumes fields have been made available noting the issue raised in https://www.drupal.org/project/civictheme/issues/3454544 🐛 Fields available but disabled in Content Types after content provisioning Active )

  13. Add Title to new page

  14. Under Banner bottom components, select Add Automated list

  15. Add relevant settings and configuration

  16. Save page

  17. Browse to the page to view. Receive the following error:

    The website encountered an unexpected error. Try again later.
    
    Error: Call to a member function id() on null in civictheme_preprocess_paragraph__civictheme_automated_list() (line 69 of themes/custom/civictheme/includes/automated_list.inc).
    
    call_user_func_array() (Line: 261)
    Drupal\Core\Theme\ThemeManager->render() (Line: 480)
    Drupal\Core\Render\Renderer->doRender() (Line: 493)
    Drupal\Core\Render\Renderer->doRender() (Line: 493)
    Drupal\Core\Render\Renderer->doRender() (Line: 240)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 404)
    __TwigTemplate_b1f9bbe54a174d5869f023fec915e121->block_content_below() (Line: 171)
    Twig\Template->displayBlock() (Line: 207)
    __TwigTemplate_b1f9bbe54a174d5869f023fec915e121->doDisplay() (Line: 394)
    Twig\Template->displayWithErrorHandling() (Line: 367)
    Twig\Template->display() (Line: 39)
    __TwigTemplate_8d0964592e3e7623b8039e14952e1033->doDisplay() (Line: 394)
    Twig\Template->displayWithErrorHandling() (Line: 367)
    Twig\Template->display() (Line: 379)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 39)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 480)
    Drupal\Core\Render\Renderer->doRender() (Line: 493)
    Drupal\Core\Render\Renderer->doRender() (Line: 240)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 130)
    __TwigTemplate_2c94d60831b98e2de04f3a385fd38b22->block_banner() (Line: 171)
    Twig\Template->displayBlock() (Line: 72)
    __TwigTemplate_2c94d60831b98e2de04f3a385fd38b22->doDisplay() (Line: 394)
    Twig\Template->displayWithErrorHandling() (Line: 367)
    Twig\Template->display() (Line: 40)
    __TwigTemplate_de34caf82f18a59318003feac87220a5->doDisplay() (Line: 394)
    Twig\Template->displayWithErrorHandling() (Line: 367)
    Twig\Template->display() (Line: 379)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 39)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 480)
    Drupal\Core\Render\Renderer->doRender() (Line: 240)
    Drupal\Core\Render\Renderer->render() (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 85)
    __TwigTemplate_5e9feeffa2a3a37553a41879b2a68388->doDisplay() (Line: 394)
    Twig\Template->displayWithErrorHandling() (Line: 367)
    Twig\Template->display() (Line: 379)
    Twig\Template->render() (Line: 38)
    Twig\TemplateWrapper->render() (Line: 39)
    twig_render_template() (Line: 348)
    Drupal\Core\Theme\ThemeManager->render() (Line: 480)
    Drupal\Core\Render\Renderer->doRender() (Line: 240)
    Drupal\Core\Render\Renderer->render() (Line: 158)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 159)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    

This error only seems to occur with Automated list on Banner bottom components.

Adding Automated list under Components instead works as expected and throws no errors.

This issue appears with versions 1.7.1 and 1.7.0.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.7

Component

Code

Created by

🇦🇺Australia thisisalistairsaccount

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

Merge Requests

Comments & Activities

  • Issue created by @thisisalistairsaccount
  • Assigned to abhishek_virasat
  • Merge request !8fix the issue → (Open) created by abhishek_virasat
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • 🇮🇳India abhishek_virasat

    @thisisalistairsaccount, fixed the issue and created MR. please review it once.

  • Status changed to Postponed: needs info 5 months ago
  • 🇦🇺Australia alex.skrypnyk Melbourne

    @thisisalistairsaccount
    If you see this occurs - something went very wrong with the list.
    For all cases on when the view would be NULL, is a watchdog record created.

    Is it possible to provide this watchdog record here?

    @abhishek_gupta1
    Appreciate the help, but we cannot simply put the missing view - the engine behind the Automated List - into a partial condition and proceed the processing as if everything is okay (as per your MR). I will wait for more information on how to reproduce this issue.

  • 🇦🇺Australia ivrh

    Same issue for me, using vanilla CivicTheme 1.7.1

    I created an automated list but omitted metadata configuration — asking it to show all page content.

    The error is:

    Error: Call to a member function id() on null in civictheme_preprocess_paragraph__civictheme_automated_list() (line 69 of /app/web/themes/custom/civictheme/includes/automated_list.inc).

    The problem is within the "_civictheme_automated_list__get_view()" function, it returns NULL on many occasions and the code within the "automated_list.inc" (line 69) unconditionally calls $view->id() (but the $view is NULL).

    I provided a workaround, please validate:
    https://github.com/civictheme/monorepo-drupal/compare/develop...ivangryn...

    It may be a better approach to trow an exception within the "_civictheme_automated_list__get_view()" function and use try/catch within the automated_list.inc file.

  • Status changed to Needs review 5 months ago
  • Assigned to alex.skrypnyk
  • 🇦🇺Australia alex.skrypnyk Melbourne

    There should not be a case when this takes place. However, hiding the error from the end-user makes sense to me.

    Noting that we already log the reason why the returned view is NULL to watchdog.

  • Status changed to Fixed 5 months ago
  • 🇦🇺Australia alex.skrypnyk Melbourne

    Updated and will be released in 1.8.

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

Production build 0.71.5 2024