"DB Error: no such field" in civicrm-core/Civi/ActionSchedule/RecipientBuilder.php
I my log files i notice an error when running the scheduled reminder cron for activities.
[db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="INSERT INTO civicrm_action_log (contact_id, entity_id, entity_table, action_schedule_id) SELECT r.contact_id as contact_id, e.id as entity_id, "civicrm_activity" as entity_table, 131 as action_schedule_id FROM civicrm_activity e INNER JOIN civicrm_contact c ON c.id = r.contact_id AND c.is_deleted = 0 AND c.is_deceased = 0 LEFT JOIN civicrm_action_log reminder ON reminder.contact_id = r.contact_id AND reminder.entity_id = e.id AND reminder.entity_table = 'civicrm_activity' AND reminder.action_schedule_id = 131 WHERE (e.activity_type_id IN (119)) AND (e.status_id IN (4)) AND (e.is_current_revision = 1 AND e.is_deleted = 0) AND (reminder.id IS NULL) AND ('20211121085238' >= DATE_SUB(e.activity_date_time, INTERVAL 16 day)) AND (DATE_SUB(20211121085238, INTERVAL 1 DAY ) <= DATE_SUB(e.activity_date_time, INTERVAL 16 day)) AND ('2020-12-31 23:00:00' <= DATE_SUB(e.activity_date_time, INTERVAL 16 day)) AND ('2022-12-30 23:00:00' > DATE_SUB(e.activity_date_time, INTERVAL 16 day)) [nativecode=1054 ** Unknown column 'r.contact_id' in 'field list']"]
I tried to debug a little and think I found that in civicrm-core/CRM/Activity/ActionMapping.php
casContactIdField is defined as r.contact_id
$query['casContactIdField'] = 'r.contact_id';
But in the above other query r.contact_id fails because civicrm_action_log has the alias of reminder and not 'r' Not sure what this breaks but it seems something that needs to be fixed