Details
Description
We have recently introduced mailing archiving, where the sizable civicrm_mailing_* tables are trimmed so that they only hold the data for mailings sent in the past 90 days. However, we soon noticed that people couldn't click on the links in emails sent more than 90 days ago, since the link refers to the civicrm_mailing_event_queue table, which was one of the tables to be trimmed (note that we didn't archive the civicrm_mailing_trackable_url table).
This surprised me, since the URL was still available. Also, if you viewed the mailing from CiviCRM, the links click through (the queueID field isn't set in that case).
Looking at the code, it's clear that it's inconsistent. If the queue ID isn't provided (but the URL ID is valid), then the URL is redirected as expected (although not tracked). However, if the queue ID is provided but not valid (with the URL ID valid), then the URL is redirected to the base URL (undesirable behaviour, not to mention unhelpful to people who are trying to view the link).
So I'm creating a pull request to align the behaviour. If there's a valid URL ID, then the page is now correctly redirected, regardless of whether the queue ID is absent, or the queue ID is present but invalid.