CRM-17959 - allow URL to be redirected if the queue ID is invalid but the URL ID...
authorAndrew Cormick-Dockery <andrew.cormick-dockery@greens.org.au>
Wed, 3 Feb 2016 05:04:48 +0000 (05:04 +0000)
committerAndrew Cormick-Dockery <andrew.cormick-dockery@greens.org.au>
Wed, 3 Feb 2016 05:04:48 +0000 (05:04 +0000)
CRM/Mailing/Event/BAO/TrackableURLOpen.php

index 8eecbd668d7346a481854608ac55259b2df36834..1ef77a9c6a6ac3c67b6a5c040e9b239eb74d14bc 100755 (executable)
@@ -79,9 +79,16 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track
     );
 
     if (!$search->fetch()) {
-      // Whoops, error, don't track it.  Return the base url.
+      // Can't find either the URL or the queue. If we can find the URL then
+      // return the URL without tracking.  Otherwise return the base URL.
 
-      return CRM_Utils_System::baseURL();
+      $search->query("SELECT $turl.url as url from $turl
+                    WHERE $turl.id = " . CRM_Utils_Type::escape($url_id, 'Integer')
+      );
+      if (!$search->fetch()) {
+        return CRM_Utils_System::baseURL();
+      }
+      return $search->url;
     }
 
     $open = new CRM_Mailing_Event_BAO_TrackableURLOpen();