Missing domain when redirecting old links
Version 1.0.21 introduced a new bug, which did not exist before the so-called refactoring.
Function params2cool() in cooluri/link.Translate.php is supposed to return a string in the form of "yourdomain.tld@path/to/subsite/" (at least on multidomain sites). However the line "return Link_Func::prepareforOutput($path,self::$conf).(empty($params)?'':$params);" only returns the part "path/to/subsite", the domain name is missing. Thus cooluri sends the browser to http://path/to/subsite//, which of course is wrong.
After digging through the code for over six hours and comparing it to verion 1.0.20, I found the reason and a workaround for this problem: Add "$path = Link_Func::prepareLinkForCache($path,self::$conf);" just before return. This will add the missing domain name to the $path variable.
To reproduce the problem on the frontend:
1. Create a new page on a multidomain site.
2. Open yourdomain.tld/index.php?id=<ID of the new page>
3. Instead of being redirected to http://yourdomain.tld/new-page/, cooluri sends your browser to http://new-page//.
4. Try to open yourdomain.tld/index.php?id=<ID of the new page> again, this time your browser will be correctlry redirected to http://yourdomain.tld/new-page/
5. Wait 24 hours (or reset the tstamp value in the database to an older date), and the problem will occur again.
#1 Updated by Jan Bednarik almost 8 years ago
- Status changed from New to Resolved
The bug wasn't caused by refactoring. Probably, it was caused by improved type handling in PHP.
When saving URL with e.g. id=10, the value 10 was considered to be string and therefore quoted in serialize function. But when the same parameters were serialized to be looked up in database, 10 was considered to be interger and thus not quoted.
Therefore, there wasn't match and so URL wasn't found in cache and when translated, domain wasn't found and then the error occured.
Fixed in SVN, will be in next version.