Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

OpenTracker - Create URL via CRM_Utils_System::externUrl() #56

Merged
merged 2 commits into from
May 28, 2020

Conversation

totten
Copy link
Member

@totten totten commented May 14, 2020

This aims to improve cooperation between flexmailer, civicrm-wordpress:wp-rest/, and civicrm/civicrm-core#17312 -- so that flexmailer produces compliant URLs.

Before

The open-tracking URL is constructed as a reference to the standalone script extern/open.php using certain $config properties.

It always links to the standalone script, even if you have a different end-point available (e.g. civicrm/mailing/open or civicrm-wordpress:wp-rest/).

After

On Civi v5.23+, it uses CRM_Utils_System::externUrl() API to request the full URL of extern/open. Flexmailer is no longer responsible for figuring the URL, and other agents (via hook_civicrm_alterExternUrl) can do so.

On Civi v5.22 and earlier, it continues using the same old formula. This provides drop-in/bug-level-compatibility on older versions. This can be removed in a couple months.

Comments

I suspect this also fixes dev/mail#17, wherein the open tracker has flawed URLs in certain multilingual configurations. However, I can't confirm for certain because I don't have that configuration.

But just to game this out...

  • If the current patch fixes dev/mail#17, then huzza!
  • If it doesn't, then the problem is in civicrm-core's CRM_Utils_System::externUrl()
    (not flexmailer:OpenTracker.php). Which means:
    • The problem already affects other use-cases in civirm-core in v5.23+.
    • The fix should go in civicrm-core.

Either way, addressing dev/mail#17 shouldn't require any further change in flexmailer.

This aims to improve cooperation between `flexmailer`, `civicrm-wordpress:wp-rest/`, and
civicrm/civicrm-core#17312 -- so that flexmailer produces compliant URLs.

Before
------

The open-tracking URL is constructed as a reference to the standalone script `extern/open.php`
using certain `$config` properties.

After
-----

On Civi v5.23+, it uses `CRM_Utils_System::externUrl()` API to request the full URL of
`extern/open`.  Flexmailer is no longer responsible for figuring the URL, and other
agents (via `hook_civicrm_alterExternUrl`) can do so.

On Civi v5.22 and earlier, it continues using the same old formula. This provides
drop-in/bug-level-compatibility on older versions. This can be removed in a couple months.

Comments
--------

I suspect this also fixes [dev/mail#17](https://lab.civicrm.org/dev/mail/issues/17),
wherein the open tracker has flawed URLs in certain multilingual configurations.
However, I can't confirm for certain because I don't have that configuration.

But just to game this out...

* If the current patch fixes dev/mail#17, then huzza!
* If it doesn't, then the problem is in `civicrm-core`'s `CRM_Utils_System::externUrl()`
  (not `flexmailer:OpenTracker.php`). Which means:
    * The problem already affects other use-cases in `civirm-core` in v5.23+.
    * The fix should go in `civicrm-core`.

Either way, addressing dev/mail#17 shouldn't require any further change in `flexmailer`.
Generally, I think the `is_callable()` formulation is better.  However, this
specific class (`CRM_Utils_System`) defines a `__callStatic()` magic-methods,
which prevents `is_callable()` from being meaningful.

So here's Plan B.
@totten
Copy link
Member Author

totten commented May 16, 2020

This was originally written/tested on roughly civicrm-core@master.

I decided to give it a whirl on 5.21 as well -- and needed to fix the compatibility test (is_callable(...) => version_compare(...) per c4f95e1). However, after fixing that, the test-suite looked good on 5.21, and I was able to successfully send a mailing via Mosaico and track the opens/click-throughs.

I guess we just need to wait for the new test run on civicrm-core@master with the updated patch.

@totten totten merged commit 7a69cc2 into civicrm:master May 28, 2020
@totten totten deleted the master-extern-url branch May 28, 2020 22:46
@jitendrapurohit jitendrapurohit mentioned this pull request Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant