Ensure the month limit is consistent with the field definition settings

Created on 3 July 2024, 6 months ago

Problem/Motivation

There's some inconsistency between the dates generated during cron and what is generated on initial field addition.

This is because the \Drupal\smart_date_recur\SmartDateRecurManager::getMonthsLimit() function expects a field definition, but is occassionally passed a SmartDateRule entity, this results in:

  1. The "Manage Instances" form showing 12 months of date instances, even if the field is configured to generate 3/6/24 months.
  2. Cron runs will always generate 12 months worth of date instances regardless of what the underlying date field is configured for.

Steps to reproduce

Create a new recurring smart date field, that only extends to 6 months.

Create a new piece of content with that date field that repeats and doesn't end.

It'll create only 6 months worth of dates, but when you go back and manage instances for the date, 12 months worth of dates are shown even though only 6 are persisted in the database.

This also has the side effect of queue/cron runs unintentionally generating 12 months worth of dates even if the field in question is configured for only 6.

Proposed resolution

Ensure that the underlying Smart Date Rule entity's field config definition is always used to determine the month limit so the behaviour is a bit more consistent.

Remaining tasks

User interface changes

N/A.

🐛 Bug report
Status

Needs review

Version

4.1

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024