Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionSchedule - Pass real batches into TokenProcessor. Simplify CRM_Activity_Tokens. #21088

Merged
merged 4 commits into from
Aug 11, 2021

Commits on Aug 11, 2021

  1. (REF) ActionSchedule - Remove unused try/catch(TokenException $e)

    This try/catch block purports to catch any exceptions of type `TokenException`.
    
    However, if you grep the source tree, you will find that `TokenException` is never thrown.
    totten committed Aug 11, 2021
    Configuration menu
    Copy the full SHA
    39eb69e View commit details
    Browse the repository at this point in the history
  2. ActionSchedule - Fill TokenProcessor will real batches

    Background: `ActionSchedule::sendMailings()` fetches a batch of pending reminders (per
    some specific schedule/rule). Then it composes and sends a message for each.
    
    Before: For each item in the batch, it makes a new `TokenProcessor`.  This
    means that the `TokenProcessor` only sees one pending reminder. Therefore, the
    `TokenProcessor` cannot meaningfully fetch batched data.
    
    After: It creates one `TokenProcessor` and adds rows for each pending
    reminder.  This means that `TokenProcessor` can fetch batched data.# On
    branch master-action-batch
    
    Comments: This part of a longer plot to simplify the `CRM_*_Tokens`.
    Currently, `CRM_*_Tokens` implements duplicate prefetch mechanisms -- the
    general-purpose `prefetch()` and the special-purpose
    `alterActionScheduleQuery()`.  This patch makes it possible to use
    `prefetch()` for all the real work of prefetching (and phasing-out
    `alterActionScheduleQuery()`).
    totten committed Aug 11, 2021
    Configuration menu
    Copy the full SHA
    c06f174 View commit details
    Browse the repository at this point in the history
  3. (REF) ActionSchedule - Pass through SQL fields named "tokenContext_*"

    This will help us to consolidate the prefetching logic in `CRM_*_Tokens`.
    
    Currently, `CRM_*_Token::alterActionScheduleQuery()` updates the query to select all fields for the entity.
    This is regardless of how many fields there are, whether they are needed, etc. This is also prone to naming conflicts.
    
    With this patch, `CRM_*_Token::alterActionScheduleQuery()` only needs to select one field (`tokenContext_fooId`). This
    will then propagate to the `TokenProcessor` which can do its own optimized data-loading.
    totten committed Aug 11, 2021
    Configuration menu
    Copy the full SHA
    3b191d7 View commit details
    Browse the repository at this point in the history
  4. CRM_Activity_Tokens - Simplify prefetch. Remove special-cases for `ac…

    …tionSearchResult`.
    
    Before: There are two distinct ways in which `CRM_Activity_Tokens` can be called, eg
    
    * For scheduled reminders, it's given `$row->context[actionSearchResult]`. The query is
      inspected for data.
    * For everything else, it's given `$row->context[activityId]`. The value is
    
    After: `CRM_Activity_Tokens` always receives activities as `$row->context[activityId]`.
    
    Comment: There are pre-existing tests for activity-based reminders and tokens in
    `CRM_Core_BAO_ActionScheduleTest` and `CRM_Activity_ActionMappingTest`.
    totten committed Aug 11, 2021
    Configuration menu
    Copy the full SHA
    9ae8e0f View commit details
    Browse the repository at this point in the history