Open andybroomfield opened 7 months ago
Discovery on this https://git.drupalcode.org/project/date_recur/-/blob/3.4.x/src/DateRecurOccurrences.php?ref_type=heads#L69-77
$isInsert = $event->isInsert();
if (!$isInsert) {
// Delete all existing values for entity and field combination.
/** @var string|int $entityId */
$entityId = $list->getEntity()->id();
$this->database->delete($tableName)
->condition('entity_id', (string) $entityId)
->execute();
}
if ($entity->getEntityType()->isRevisionable() && $entity instanceof RevisionableInterface) {
$fields[] = 'revision_id';
$baseRow['revision_id'] = $entity->getRevisionId();
}
So what is happening is that every time an event is saved, the date occurances table for that node gets deleted, and new calculated dates added, but only for the current saved revision, which might not be a published one, and that is breaking the query in views.
However it is a service / event subscriber, so maybe there is a way to override this without patching. https://git.drupalcode.org/project/date_recur/-/blob/3.4.x/date_recur.services.yml?ref_type=heads#L6-10
date_recur.occurrences:
class: Drupal\date_recur\DateRecurOccurrences
arguments: ['@database', '@entity_field.manager', '@typed_data_manager', '@entity_type.manager']
tags:
- { name: 'event_subscriber' }
Sounds like a bug upstream to me. Wouldn't you want the published version (if there is) to be the one that you calculate the views values for? At least by default.
Very old patch here https://www.drupal.org/project/date_recur/issues/3010184#comment-13156851 Would be worth trying to see if this applies.
BHCC has applied this patch, might be worth including here in case it comes up for others.
When creating a new revision of an event, or an event has a scheduled transition to review, it falls off the event listing.
Steps to reproduce
Note that the event, even though still having a published revision, is no longer on the events view.
I did quite a lot of digging on this one, I found that the DB table
date_recur__node__localgov_event_date
contains both anentity_id
andrevision_id
. However the revision_id is always the latest revision, not the default revision.Looking at the events views SQL query, there is a join to revision
Views query below, which includes BHCC fields.