This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
(dev/mail#20) Mailing.preview - Fix regression circa Civi 5.6.x #38
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
totten
force-pushed
the
master-preview-512
branch
from
April 27, 2019 00:34
c774836
to
9b68843
Compare
totten
changed the title
(dev/mail#20) Mailing.preview - Fix regression circa Civi 5.6.x
(WIP) (dev/mail#20) Mailing.preview - Fix regression circa Civi 5.6.x
Apr 27, 2019
totten
force-pushed
the
master-preview-512
branch
from
April 29, 2019 21:04
9b68843
to
812d53e
Compare
totten
added a commit
to totten/civicrm-core
that referenced
this pull request
Apr 29, 2019
…essor/Flexmailer Overview -------- When using `TokenProcessor` to generate a mailing (e.g. as with Flexmailer/Mosaico), the action-tokens (e.g. `{action.optOutUrl}`) are generated via `CRM_Mailing_ActionTokens`. To properly generate them, `CRM_Mailing_ActionTokens` relies on certain information (e.g. mailing/job ID). However, that information is no longer available when performing a "Preview" -- leading to misbehavior in previews. This patch allows Flexmailer to restore parity for previewing those tokens. Note: This is a pre-requisite for the full fix civicrm/org.civicrm.flexmailer#38 Before (Pre-5.6) ---------------- * When a user begins composing a mailing, CiviMail creates a draft mailing with a concrete ID (e.g. `mailing civicrm#123`). * To preview the mailing, the UI calls `Mailing.preview` API with the ID of the mailing. * Flexmailer/Mosaico generates the preview by calling `TokenProcessor` and therefore `CRM_Mailing_ActionTokens`. * `CRM_Mailing_ActionTokens` has strictness checks. These pass because the ID is available. Before (5.6-5.12) ---------------- As a performance enhancement, CiviCRM 5.6 (PR civicrm#12509; [dev/mail#20](https://lab.civicrm.org/dev/mail/issues/20)) revised the signature for `Mailing.preview` API to allow previews *without* having a specific mailing record/job/ID. Consequently: * When a user begins composing a mailing, CiviMail creates a draft mailing with a concrete ID (e.g. `mailing civicrm#123`). * To preview the mailing, the UI calls `Mailing.preview` API ~~with~~ **without** the ID of the mailing. * Flexmailer/Mosaico generates the preview by calling `TokenProcessor` and therefore `CRM_Mailing_ActionTokens`. * `CRM_Mailing_ActionTokens` has strictness checks. These ~~pass~~ **fail** because the ID is ~~available~~ **unavailable**. After ---------------- * When a user begins composing a mailing, CiviMail creates a draft mailing with a concrete ID (e.g. `mailing civicrm#123`). * To preview the mailing, the UI calls `Mailing.preview` API ~~with~~ **without** the ID of the mailing. * Flexmailer/Mosaico generates the preview by calling `TokenProcessor` and therefore `CRM_Mailing_ActionTokens`. * `CRM_Mailing_ActionTokens` has ~~strictness~~ **less strict** checks. These **pass** because the `context[schema]` hints that a mailing ID *will be available* when needed.
totten
added a commit
to totten/civicrm-core
that referenced
this pull request
Apr 29, 2019
…essor/Flexmailer Overview -------- When using `TokenProcessor` to generate a mailing (e.g. as with Flexmailer/Mosaico), the action-tokens (e.g. `{action.optOutUrl}`) are generated via `CRM_Mailing_ActionTokens`. To properly generate them, `CRM_Mailing_ActionTokens` relies on certain information (e.g. mailing/job ID). However, that information is no longer available when performing a "Preview" -- leading to misbehavior in previews. This patch allows Flexmailer to restore parity for previewing those tokens. Note: This is a pre-requisite for the full fix civicrm/org.civicrm.flexmailer#38 Before (Pre-5.6) ---------------- * When a user begins composing a mailing, CiviMail creates a draft mailing with a concrete ID (e.g. `mailing civicrm#123`). * To preview the mailing, the UI calls `Mailing.preview` API with the ID of the mailing. * Flexmailer/Mosaico generates the preview by calling `TokenProcessor` and therefore `CRM_Mailing_ActionTokens`. * `CRM_Mailing_ActionTokens` has strictness checks. These pass because the ID is available. Before (5.6-5.12) ---------------- As a performance enhancement, CiviCRM 5.6 (PR civicrm#12509; [dev/mail#20](https://lab.civicrm.org/dev/mail/issues/20)) revised the signature for `Mailing.preview` API to allow previews *without* having a specific mailing record/job/ID. Consequently: * When a user begins composing a mailing, CiviMail creates a draft mailing with a concrete ID (e.g. `mailing civicrm#123`). * To preview the mailing, the UI calls `Mailing.preview` API ~~with~~ **without** the ID of the mailing. * Flexmailer/Mosaico generates the preview by calling `TokenProcessor` and therefore `CRM_Mailing_ActionTokens`. * `CRM_Mailing_ActionTokens` has strictness checks. These ~~pass~~ **fail** because the ID is ~~available~~ **unavailable**. After ---------------- * When a user begins composing a mailing, CiviMail creates a draft mailing with a concrete ID (e.g. `mailing civicrm#123`). * To preview the mailing, the UI calls `Mailing.preview` API ~~with~~ **without** the ID of the mailing. * Flexmailer/Mosaico generates the preview by calling `TokenProcessor` and therefore `CRM_Mailing_ActionTokens`. * `CRM_Mailing_ActionTokens` has ~~strictness~~ **less strict** checks. These **pass** because the `context[schema]` hints that a mailing ID *will be available* when needed.
…x (dev/mail#20) Flexmailer overrides the `Mailing.preview` API. In civicrm/civicrm-core#12509 (5.6), it became possible to call `Mailing.preview` without an `id` for the mailing. This update Flexmailer `Mailing.preview` to also work without an ID, and it expands unit-test coverage to ensure correct operation with or without an ID.
….x (dev/mail#20)
totten
force-pushed
the
master-preview-512
branch
from
April 29, 2019 23:45
812d53e
to
a07c899
Compare
totten
changed the title
(WIP) (dev/mail#20) Mailing.preview - Fix regression circa Civi 5.6.x
(dev/mail#20) Mailing.preview - Fix regression circa Civi 5.6.x
Apr 30, 2019
Note: The expanded test-coverage correctly reports a failure - and it won't be fully resolved until civicrm/civicrm-core#14156 is merged. However, if I run the tests locally and include that patch, then they pass. |
/test |
/test |
1 similar comment
/test |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Flexmailer overrides the
Mailing.preview
API. Incivicrm/civicrm-core#12509 (5.6), it became possible
to call
Mailing.preview
without anid
for the mailing.This update Flexmailer
Mailing.preview
to also work without an ID.It resolves a symptom in which clicking "Preview as (HTML/Text)" seems to work - but renders
mailing#1
instead of rendering the actual draft mailing.