I think I've got it (and learned a lot in the process):
diff --git a/web/core/modules/views/src/EntityViewsData.php b/web/core/modules/views/src/EntityViewsData.php
index xxxxxxx..yyyyyyy 100644
--- a/web/core/modules/views/src/EntityViewsData.php
+++ b/web/core/modules/views/src/EntityViewsData.php
@@ -387,7 +387,7 @@
$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) {
+ if ($storage_definition && !$storage_definition->isBaseField() && $storage_definition instanceof BaseFieldDefinition) {
$field_storage = BaseFieldStorageConfigWrapper::createFromBaseFieldDefinition($storage_definition);
views_collect_field_view_data($field_storage, $data);
}
Thank you @owenbush for your help. It would be great if this could be added as a patch on Drupal in case others experience the same issue.
Omitting
this patch β
(from
EntityViewsData assumes BaseFieldDefinitions...
π
EntityViewsData assumes BaseFieldDefinitions where it should use FieldDefinitionInterface
Needs work
)
and Changing line 390
from:
if (!$storage_definition->isBaseField() && $storage_definition instanceof BaseFieldDefinition) {
to:
if ($storage_definition && !$storage_definition->isBaseField() && $storage_definition instanceof BaseFieldDefinition) {
Resolves the issue.
Here's a patch generated by Cody for the above, but it does not apply (Hunk #1 FAILED at 390)
diff --git a/web/core/modules/views/src/EntityViewsData.php b/web/core/modules/views/src/EntityViewsData.php
index xxxxxxx..yyyyyyy 100644
--- a/web/core/modules/views/src/EntityViewsData.php
+++ b/web/core/modules/views/src/EntityViewsData.php
@@ -390,7 +390,7 @@ class EntityViewsData implements EntityViewsDataInterface {
$storage_definition = isset($storage_definitions[$field_name]) ? $storage_definitions[$field_name] : NULL;
- if (!$storage_definition->isBaseField() && $storage_definition instanceof BaseFieldDefinition) {
+ if ($storage_definition && !$storage_definition->isBaseField() && $storage_definition instanceof BaseFieldDefinition) {
$field_storage = BaseFieldStorageConfigWrapper::createFromBaseFieldDefinition($storage_definition);
views_collect_field_view_data($field_storage, $data);
}
I'd greatly appreciate any help with a patch.
Thanks owenbush.
This gets very interesting. The offending code was supplied by a patch that I added
https://www.drupal.org/files/issues/2021-11-09/2930736-44.patch β
(from issue:
EntityViewsData assumes BaseFieldDefinitions where it should use FieldDefinitionInterface
π
EntityViewsData assumes BaseFieldDefinitions where it should use FieldDefinitionInterface
Needs work
)
The error is present without the patch.
the error persists with the patch.
The error goes away when a portion of the code supplied by the patch is commented out.
Conclusion: Something in the patch effectively solves the problem, but is negated by the offending portion of the code.
Unfortunately I don't understand code enough to know what is effective and how to isolate it from the rest of the code.
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 )
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.
GarChris β created an issue.
All pages are affected.
Steps to reproduce:
- Install the module - composer require 'drupal/recurring_events:^2.0'
- Everything works fine - able to add events
- Clear Cache
- Visit any page - "The website encountered an unexpected error. Please try again later."
Some background:
- 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.
- Site was upgraded from Drupal 8
- Possibility that it's trying to find a deleted view? Any way to check this?
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?
GarChris β created an issue.