As you can see, I’m passing parameters to actionIndex. The default value for $list is ‘context1’. When I pass ‘context2’ as a paramter (site/index/list/context2), the code in ‘context1’ executes, somehow. This is really hard to explain and probably won’t make a lot of sense but the ‘context2’ html is actually being rendered even though the block of code under ‘context1’ is entered and executed, at least to the point of setting the state value of ‘context’ to ‘context1.’ All of this happens before I make the ajax call. So, I was a bit mistaken about that.
Still not sure why is it behaving like this. I’m continuing to test.
I did try that–same result. I have the url manager setup to accept the optional paths. This has worked correctly. It has been displaying the correct html for each context. The only reason I became aware of this issue is when I wanted to make an ajax call. In the ajax call, I test for the context. But, the problem is not in the ajax call, the problem is that both code blocks are being executed when I am in context2. I know this for a fact because if I add an exit statement in the code block for context1 prior to setting the context, if works as expected. I also send myself an email, for testing, when in context2. I receive the email and the correct html is displayed. If I add print statement in the context1 block, I’ll recieve the email but won’t see the print statement text.
So you suggest that generally it works OK, beside this testing email that is sent from context2 event if you are in context1 (and the only sympthom of execution context1 is sent mail)? Or perhaps I mistunderstood something?
I do not know how far I have perceived your problem.
Anyway I am curious to test your code.
class TrialController extends Controller
public function actionContext($name)
public function actionAjax()
Yeah, that’s basically what I’m saying. I created a test case and wasn’t able to reproduce the issue. Must be something in my actionIndex that is causing the issue. I’ll need to more testing. See in post below the test case.
I also created a test case trying to reproduce the issue. Looks like there is something in my project code that is causing the issue. The fact is I should refactor my code into two actions instead of what I have.
Thanks for taking the time to create the example. A facsimile of the structure causing the issue is below.
The exception in this case was a missing image in a css file. You can see that the exception was occurring in context2 with a redirect to site/index. The redirect would then use the default value of $list (the param passed into actionIndex) causing context1’s code block to execute thus resetting the state value (ctx).
'REDIRECT_STATUS' => '200',
'HTTP_ACCEPT' => 'image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5',
'HTTP_REFERER' => 'http://.../site/index?list=friends', //friends == context2 in the example
'REDIRECT_URL' => '/css/images/ui-bg_flat_75_ffffff_40x100.png',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'REQUEST_METHOD' => 'GET',
'QUERY_STRING' => '',
'REQUEST_URI' => '/css/images/ui-bg_flat_75_ffffff_40x100.png',
'SCRIPT_NAME' => '/index.php',
'PHP_SELF' => '/index.php',
'REQUEST_TIME' => 1364369223,
2013/03/27 01:27:03 [error] [unhandled exception caught at index.php] Unable to resolve the request "css/images/ui-bg_flat_75_ffffff_40x100.png".
in /var/www/dkeidkd838dkckde32/index.php (34)
A couple things I don’t understand.
Why would a missing image throw an exception?
2 Why context2 was rendered correctly, even though context1’s code block was also entered.
I should have imagined that. Some browser repeats the same request for a page twice, when it failed to receive all the resources for the page. Missing images (sometimes "favicon.ico") will trigger this, and it will be a cause of the problems in session data.