Details
Description
When you create new A/B test in CiviMail and when you use the same link in both text versions (A and B) then CiviCRM returns invalid url. This case occurs in all test type.
mysql> select * from civicrm_mailing_trackable_url where mailing_id in (776 /* A */, 777 /* B */);
id | url | mailing_id |
1996 | http://www.example.org/?var=only-html | 776 |
1997 | http://www.example.org/?var=common | 776 |
1998 | http://www.example.org/?var=only-text | 776 |
1999 | http://www.example.org/?var=only-html | 777 |
2000 | http://www.example.org/?var=common | 777 |
And then only-text link in Mailing B has url_id = 1998. This is invalid behaviour because url_id = 1998 is linked with mailing_id = 776 not with mailing_id = 777.
Proper result have to be like this:
id | url | mailing_id |
1996 | http://www.example.org/?var=only-html | 776 |
1997 | http://www.example.org/?var=common | 776 |
1998 | http://www.example.org/?var=only-text | 776 |
1999 | http://www.example.org/?var=only-html | 777 |
2000 | http://www.example.org/?var=common | 777 |
2001 | http://www.example.org/?var=only-text | 777 |
This can be achieved by extending key for cache array by adding mailing_id
https://github.com/civicrm/civicrm-core/blob/master/CRM/Mailing/BAO/TrackableURL.php#L61
I'm going to prepare PR