Welcome Guest, Not a member yet? Register   Sign In
redirect( 'xxx' ) not working properly
#1
Question 

Hi,
I have upgraded from CI 4.0.3 to the latest version. Working through the required changes to my code, all seems clear, except this issue. At one place the code uses a redirect( 'login' ) function. This results in an attempt to navigate to https://login/login. After some investigation i was able to determine the reason, not sure what's causing it though. Any help appreciated.
Here is the call stack at the moment things go wrong:
PHP Code:
/Users/JanZ/Sites/nexus2/system/HTTP/SiteURI.php.CodeIgniter\HTTP\SiteURI->determineBaseURL(): lineno 147 
/Users/JanZ/Sites/nexus2/system/HTTP/SiteURI.php.CodeIgniter\HTTP\SiteURI->__construct(): lineno 102 
/Users/JanZ/Sites/nexus2/system/HTTP/SiteURI.php.CodeIgniter\HTTP\SiteURI->siteUrl(): lineno 428 
/Users/JanZ/Sites/nexus2/system/Helpers/url_helper.php.site_url(): lineno 39 
/Users/JanZ/Sites/nexus2/system/HTTP/RedirectResponse.php.CodeIgniter\HTTP\RedirectResponse->route(): lineno 67 
/Users/JanZ/Sites/nexus2/system/Common.php.redirect(): lineno 853 
/Users/JanZ/Sites/nexus2/app/ThirdParty/myth-auth/Filters/LoginFilter.php.Myth\Auth\Filters\LoginFilter->before(): lineno 74 
/Users/JanZ/Sites/nexus2/system/Filters/Filters.php.CodeIgniter\Filters\Filters->runBefore(): lineno 203 
/Users/JanZ/Sites/nexus2/system/Filters/Filters.php.CodeIgniter\Filters\Filters->run(): lineno 184 
/Users/JanZ/Sites/nexus2/system/CodeIgniter.php.CodeIgniter\CodeIgniter->handleRequest(): lineno 481 
/Users/JanZ/Sites/nexus2/system/CodeIgniter.php.CodeIgniter\CodeIgniter->run(): lineno 355 
/Users/JanZ/Sites/nexus2/system/Boot.php.CodeIgniter\Boot::runCodeIgniter(): lineno 325 
/Users/JanZ/Sites/nexus2/system/Boot.php.CodeIgniter\Boot::bootWeb(): lineno 67 
/Users/JanZ/Sites/nexus2/public/index.php.{main}(): lineno 56 
The site_url function (url_helper.php, line 33) calls the service( 'request' )->getURI() function and the resulting object has the property $host set to "". So when the code gets to SiteURI->determineBasseURL, the $host parameter is not NULL but has a value of "" instead. As a result, even though the created $uri object has the correct value for the $host property, this code starting on line 159 clears it out:
PHP Code:
        if ($host !== null) {
            $uri->setHost($host);
        

It seems like an additional check for $host being an empty string is the solution, but there is still a high probability I have something somewhere configured wrong. Any help would be greatly appreciated.
Thanks!
Reply
#2

Hi, this is now fixed, the issue was exactly the same as described here: https://forum.codeigniter.com/showthread.php?tid=91684
The solution to be found there as well.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB