I’m new to Yii. Right now I am using version 1.1.4 for a company project. Started to flesh an application from the skeleton the framework tool generates and borrowed some code from the “Blogs” demo, specifically the log-in page.
I defined my own CWebApplication-derived class, lets call it MyWebApp, located in /protected/MyWebApp.php; and then hooked it in on the index.php file at the application root. The purpose of extending CWebApplication is for redirecting any non-logged-in user, trying to access actions other than "site/login" or "site/error", to the log-in page.
Here’s the thing, if I type the address “http://localhost/mysite/” in the browser (Firefox 3.6.9) I get some strange behavior, inspected by the use of FireBug:
First, I get one 302 HTTP status with a response text "Failed to load source for: http://localhost/mysite/" with a Location header pointing to "http://localhost/mysite/index.php/site/login".
This is (kind of) expected, but the problem is that the next request to that redirection address, although it gets a 200 HTTP status, the page HTML code is returned twice from the server, i.e: the page starts with <html>, then comes the <head> and <body>, then the page ends with </html> and then it repeats all over again.
I checked the layouts, the view, the controller to see if there could be a duplicate call to $this->render(), but everything seems to be fine. And strange enough, once logged-in, when I click the "log-out" link, the process generates two redirections and the HTML output gets repeated thrice. Once again, the redirections are expected because this is the logic implemented: the "site/logout" action executes and redirects to the Yii::app()->homeUrl, MyWebApp hooks the beforeControllerAction method and redirects to "site/login".
I’ve got my head crack-open and bumped for two days now and haven’t had any luck. Anyone shedding some light or insight of why this could be happening, please speak up. Any ideas are quite welcome.
Thanks.