What can go wrong on switching application-context in symfony 1.4

Flattr this
Tweet this: What can go wrong on switching application-context in symfony 1.4
Dent this: What can go wrong on switching application-context in symfony 1.4
Tags: crud, symfony1
Datum: 07.03.2012 20:04:39
It's was the end of my first week after the winter holidays and I noticed something strange in the working branch of the base applications backend. Most parts of this backend were based on the admingenerator. Each plugin hooks itself into the backend, includes menus, configuration and has generator based CRUDs for its models.

Listing, editing, creating new entries all no problem. But deleting wasn't possible in the list-view, it always showed me the errorpage of symfony, deleting an entry from the edit-page worked.

Switching to dev-mode showed me a csrf-warning. I cleared cleared and reset everything related to the application, deleted the sessions, restarted all services related, reset the database, created a new entry and tried to delete it ... again failing.

Last point where it worked: before the holidays. Since I was the only developer touching the code, there wasn't anybody else to blame.

Switching to another plugins generators, some had the bug, some didn't, now it was really getting weird, since all use the same modified theme as base, configurations was nearly the same.

After hacking around with the generator.yml, trying everything and not getting anywhere I choose to just go back in time. Thanks to git aka version control, I went back commit by commit in a plugin which had the problem and it showed me where the problem was located.

The problem was introduced by what looked like a simple feature short before the holidays: Linking from the admingenerator-list to the entries in the frontend by using the frontends context.

After finding Accessing the frontend routing from the backend application and modifiying it a bit I used it to create columns in some generator lists which fetched the frontend-router and generated the url by using the router.

Everything was perfect, expect, switching back with sfContext::switchTo($current_application); wasn't really enough to switch back to the backend-application. It reset sfConfig and some other things, but doesn't call sfApplicationConfiguration->initConfiguration(); which usally runs
if (false !== sfConfig::get('sf_csrf_secret'))
So what you need to do is running an additional
after running the switchTo, else you application will use the csrf-tokens from the application you switched to and it probably has more sideaffects.

Trackbacks (0)

Trackbackurl: http://www.robo47.net/trackback/blogentry/216

Es sind keine Trackbacks vorhanden.

Kommentare (0)

Es sind noch keine Kommentare vorhanden.

Die Kommentare zu diesem Beitrag sind gesperrt.

You liked it ? Link it on your homepage or blog: