New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a fallback for redirect urls #10670
Conversation
|
||
// If no published redirect was found try with the server-relative URL | ||
if (!$link || ($link->published != 1)) | ||
$dbo = JFactory::getDbo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core had at one point standardized on using $db
for all database object references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I've changed the lines to use $db instead of $dbo, we should then update / change the CodeSniffer rules since they discourage having variables shorter than three characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matrikular there is a possibility that we might be able to customize the variable length check with an exception for $db
. Generally, I think we should keep the standard to at least Three characters and make a few limited exceptions for things like $db. That or we should fix all of the $db
references to $dbo
so that it complies with the actual written standard and quite trying to have standards that violate our other standards.
left hand doesn't know what the right hand is doing...
I would like to point out, that the promoted CodeSniffer Rules discourage having variable names shorter than three characters.
I have tested this item ✅ successfully on 53b4277 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10670. |
I have tested this item ✅ successfully on 53b4277 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10670. |
RTC based on testing thanks 👍 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10670. |
Sorry the This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10670. |
Merged - thanks! |
Introduction
The current implementation of the redirect application (component and plugin) expects a direct match to act uppon. So, if one wants to manually add a "rewrite rule" for e.g. http(s)://www.domain.tld/path/some-alias?some=param the rule would have to be exactly that url.
There are a couple of scenarios where query params could be added to any url, like when using a newsletter tool or if you've implemented certain affiliate mechanisms, where, especially in case of a relaunch of a website, you would have to create a whole bunch of redirect rules for each and every newsletter and / or affliiate link. Seldom this amount of different redirects can or should be handled via rewrite rules in a .htacces file.
This PR will add to the default behavior in a way that, if no specific (and published) redirect rule was found, it keeps looking for a "fallback".
Here is an example (behavior without the patch).:
If no (published) redirect rule for http(s)://www.domain.tld/path/some-alias?some=param exists, it will lead to a 404 status code.
After the patch, the plugin would also find http(s)://www.domain.tld/path/some-alias and would append the missing params automatically to the redirect url.
Summary of Changes
$app = JFactory::getApplication(); or $uri = JUri::getInstance();
are common practice and should not need to be explained.Testing Instructions