qcubed/framework — pull request #182 by spekary (2013-03-15 06:19:42+00:00)
Title: Fixing problem with multiple windows.

If you have two QCubed windows open, you could clobber a formstate, and get the dreaded PHP_Incomplete_Cast error. The scenario is this:

1) Form1 pops up Form2 with an ajax call. formstate_1 is created for Form1, and formstate_2 is created for Form2.
2) Form1 does an ajax call, which sets blnBackupButton to false. The session remembers that the last formstate created was #2. It thinks it does not have to increment the formstate number because blnBackupButton is false, so it creates formstate_2 for Form1.
3) Form2 tries to do an ajax call, and tries to unserialize formstate_2, because that is what is saved in the form. This then crashes, because formstate_2 now contains Form1, and not Form2.

The other formstate handlers do not appear to try to reuse formstate ids, so they are fine. This fix will result in a more rapid increase in the size of the session, but it can't be avoided unless we implement some kind of garbage collection scheme. Perhaps in the future we can simply detect what the old formstate id was and delete the old formstate when we create a new one. A task for another day.