Call to a member function isBaseField() on null

Created on 20 June 2024, 8 days ago
Updated 27 June 2024, about 12 hours ago

Error: Call to a member function isBaseField()

Site goes down with the following error after enabling the module and clearing the cache:
on null in Drupal\views\EntityViewsData->getViewsData() (line 390 of web/core/modules/views/src/EntityViewsData.php) #0 web/core/modules/views/views.views.inc(180): Drupal\views\EntityViewsData->getViewsData()

Website Info:
Drupal: 9.5.11
PROFILE: Opigno LMS 3.1.0
PHP: 8.1.13
Memory limit: 128M
Web Server: nginx/1.23.2
Database: 10.6.18-MariaDB-0ubuntu0.22.04.1

Full Error (Note: error details changes each time)

Error: Call to a member function isBaseField() on null in Drupal\views\EntityViewsData->getViewsData() (line 390 of  web/core/modules/views/src/EntityViewsData.php)
#0  web/core/modules/views/views.views.inc(180): Drupal\views\EntityViewsData->getViewsData()
#1  web/core/modules/views/src/ViewsData.php(236): views_views_data()
#2  web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\views\ViewsData->Drupal\views\{closure}()
#3  web/core/modules/views/src/ViewsData.php(244): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#4  web/core/modules/views/src/ViewsData.php(154): Drupal\views\ViewsData->getData()
#5  web/core/modules/views/src/Plugin/ViewsHandlerManager.php(85): Drupal\views\ViewsData->get()
#6  web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(888): Drupal\views\Plugin\ViewsHandlerManager->getHandler()
#7  web/core/modules/views/src/ViewExecutable.php(1045): Drupal\views\Plugin\views\display\DisplayPluginBase->getHandlers()
#8  web/core/modules/views/src/ViewExecutable.php(903): Drupal\views\ViewExecutable->_initHandler()
#9  web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2318): Drupal\views\ViewExecutable->initHandlers()
#10  web/core/modules/views/src/ViewExecutable.php(1697): Drupal\views\Plugin\views\display\DisplayPluginBase->preExecute()
#11  web/core/modules/views/src/ViewExecutable.php(1632): Drupal\views\ViewExecutable->preExecute()
#12  web/core/modules/views/src/Element/View.php(81): Drupal\views\ViewExecutable->executeDisplay()
#13 [internal function]: Drupal\views\Element\View::preRenderViewElement()
#14  web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()
#15  web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback()
#16  web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback()
#17  web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#18  web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(242): Drupal\Core\Render\Renderer->render()
#19  web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#20  web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(243): Drupal\Core\Render\Renderer->executeInRenderContext()
#21  web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(132): Drupal\Core\Render\MainContent\HtmlRenderer->prepare()
#22  web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
#23 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
#24  web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#25  vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#26  vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#27  web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#28  web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#29  web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#30  web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#31  web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#32  web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#33  web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#34  vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#35  web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#36  web/index.php(19): Drupal\Core\DrupalKernel->handle()
#37 {main}
πŸ› Bug report
Status

Active

Version

2.0

Component

Recurring Events (Main module)

Created by

πŸ‡ΊπŸ‡ΈUnited States GarChris

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

Comments & Activities

  • Issue created by @GarChris
  • πŸ‡ΊπŸ‡ΈUnited States owenbush Denver, CO

    Hey there,

    I suspect, based on your versions, that this is actually the following core issue πŸ“Œ Allow adding computed bundle fields in Views Fixed , that has been resolved for I think 10.2+ but not backported to 9.x

    I think this old MR that was targeting the 9.5.x branch should still work for you:

    https://git.drupalcode.org/project/drupal/-/merge_requests/2511.diff

  • πŸ‡ΊπŸ‡ΈUnited States GarChris

    Thanks for your quick response, Owenbush. I applied the the patch but still getting the error. Any other suggestion - really need to get this working?

  • πŸ‡ΊπŸ‡ΈUnited States owenbush Denver, CO

    Do you get this error on all pages or only on views pages? The patch I linked to fixes a bug when an inherited field is added to a view, because inherited fields are computed fields and Drupal core did not support computed bundle basefields in views until that patch merged.

    But if you were not on a view page, then there may be something else at play. Can you give steps to recreate the bug?

    Thanks.

  • πŸ‡ΊπŸ‡ΈUnited States GarChris

    All pages are affected.
    Steps to reproduce:

    1. Install the module - composer require 'drupal/recurring_events:^2.0'
    2. Everything works fine - able to add events
    3. Clear Cache
    4. Visit any page - "The website encountered an unexpected error. Please try again later."

    Some background:

    1. Running Opigno LMS, which does not allow upgrading beyond current core version. It also has a calendar view with a "recur" field. Not sure if that has any impact.
    2. Site was upgraded from Drupal 8
    3. Possibility that it's trying to find a deleted view? Any way to check this?
  • πŸ‡ΊπŸ‡ΈUnited States GarChris

    I've been experimenting:
    Installed a fresh copy of Drupal 9.5.11. Installed Recurring Events. Cleared cache. Everything works fine.
    Installed a fresh copy of Drupal Opigno. Crashed as soon as I installed Recurring Events and cleared cache.

    Below is the section of code (in web/core/modules/views/src/EntityViewsData.php) that's triggering this error.

        // Add any bundle fields defined in code.
        // @todo Here we are assuming that hard-coded bundle field definitions
        //   extend BaseFieldDefinition, which is a common case. Revisit this logic
        //   in https://www.drupal.org/project/drupal/issues/2930736.
        $storage_definitions = $this->entityFieldManager->getFieldStorageDefinitions($this->entityType->id());
        foreach (BaseFieldStorageConfigWrapper::getFieldBundles($this->entityType->id()) as $field_name => $bundles) {
          $storage_definition = isset($storage_definitions[$field_name]) ? $storage_definitions[$field_name] : NULL;
          if (!$storage_definition->isBaseField() && $storage_definition instanceof BaseFieldDefinition) {
            $field_storage = BaseFieldStorageConfigWrapper::createFromBaseFieldDefinition($storage_definition);
            views_collect_field_view_data($field_storage, $data);
          }
        }
    
        return $data;
      }
    

    If I comment out this portion

    //      if (!$storage_definition->isBaseField() && $storage_definition instanceof BaseFieldDefinition) {
    //        $field_storage = BaseFieldStorageConfigWrapper::createFromBaseFieldDefinition($storage_definition);
    //        views_collect_field_view_data($field_storage, $data);
    //      }
        }
    

    The error goes away. But I'm no coder so I don't know what to do from here. I greatly appreciate your help.

  • πŸ‡ΊπŸ‡ΈUnited States GarChris

    There is an error in the Opigno Calendar View that might be related. Posted an issue in the Opigno issue queue but posting here as well for additional context:
    In /view/opigno_calendar/edit/page_week:

    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'range_intersects '202426')) AND (("opigno_calendar_event_field_data"."status"...' at line 8: SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "opigno_calendar_event_field_data" "opigno_calendar_event_field_data" LEFT JOIN "opigno_calendar_event__date_daterange" "opigno_calendar_event__date_daterange" ON opigno_calendar_event_field_data.id = opigno_calendar_event__date_daterange.entity_id AND opigno_calendar_event__date_daterange.deleted = :views_join_condition_0 LEFT JOIN "opigno_calendar_event__635d6bfb18" "opigno_calendar_event__635d6bfb18" ON opigno_calendar_event_field_data.id = opigno_calendar_event__635d6bfb18.entity_id WHERE ((DATE_FORMAT((opigno_calendar_event__date_daterange.date_daterange_value + INTERVAL -14400 SECOND), '%Y%v') range_intersects :opigno_calendar_event__date_daterange_date_daterange_value_year_week)) AND (("opigno_calendar_event_field_data"."status" = :db_condition_placeholder_0) AND (("opigno_calendar_event__635d6bfb18"."field_calendar_event_members_target_id" IS NULL) OR ("opigno_calendar_event__635d6bfb18"."field_calendar_event_members_target_id" = :db_condition_placeholder_1)))) "subquery"; Array ( [:opigno_calendar_event__date_daterange_date_daterange_value_year_week] => 202426 [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 2 [:views_join_condition_0] => 0 )
    
  • πŸ‡ΊπŸ‡ΈUnited States owenbush Denver, CO

    This took a while to track down, but what is interesting about the error you get and referenced is that code is not actually in Drupal core yet.

    It seems to be part of this issue πŸ› [PP-1] bundleFieldDefinitions() are not added in EntityViewsData Needs work in patches up to, and including, #28. But this code has changed since that patch (to get it to work with D10/11), and has not been merged to core.

    So it seems like something somewhere is applying that patch to core, and that is inadvertently breaking this functionality.

    Is that something in your composer.json file, or perhaps in one of the composer.json files associated with Opigno?

Production build 0.69.0 2024