-
What can go wrong on switching application-context in symfony 1.4
07.03.2012 20:04
It's was the end of my first week after the winter holidays and I noticed something strange in theworkingbranch 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 withsfContext::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 runsif (false !== sfConfig::get('sf_csrf_secret')) { sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret')); }So what you need to do is running an additional$current_configuration->initConfiguration();after running the switchTo, else you application will use the csrf-tokens from the application you switched to and it probably has more sideaffects. Weiterlesen: What can go wrong on switching application-context in symfony 1.4Kommentare: 0 -
WYSIWYG Editor for Markdown and reStructuredText on Linux / Ubuntu
06.03.2012 20:04
Because I sometimes miss a needed linebreak or my lists don't look like expected in Markdown or reStructuredText (mainly for use with sphinx), I was looking for a better editor with some kind of live preview for linux. Normally I edited those files directly in Netbeans or Gedit. I found ReText a nice Gui-Editor written in python with QT for the frontend. It does exactly what i wanted, 2 Columns, one with markdown or reStructuredText, the other shows a live preview. For Ubuntu there is a PPA: https://launchpad.net/~mitya57/+archive/ppa which includes integration into the menu and you don't have to create the entry yourself to automatically open files If you don't install via the PPA you have to create the menu-entry yourself to be able to automatically open files with it since Ubuntu seems to no more support opening files with programs which aren't installed in the menu: Add Custom command in the Open with dialog. Weiterlesen: WYSIWYG Editor for Markdown and reStructuredText on Linux / UbuntuKommentare: 0 -
Extending Heise SocialSharePrivacy to pass a dynamic title to twitter
07.12.2011 20:02
Yesterday I had a look at Heise SocialSharePrivacy and experimented around with it (probably will integrate it here via a plugin) but one think I was missing was a way to use it on a list of items, while having different titles for the twitter text, not using the current pages title. Currently it only allows for a static title or a function. But the function was worthless in this case, since I wanted to use the title each specific link. Weiterlesen: Extending Heise SocialSharePrivacy to pass a dynamic title to twitterKommentare: 0 -
ReflectionException: Method PHPUnit_Framework_Warning::Warning() does not exist
30.11.2011 19:59
If you ever getReflectionException: Method PHPUnit_Framework_Warning::Warning() does not exist
That may be because you are using @dataProvider and your dataProvider returns the data in an invalid way. This may be caused by forgetting one dimension in the returned array when using only a single value as parameter for the test. Wrong:<?php public function myDataProvider() { $data = array(); $data[] = 'some value i want to pass as param'; $data[] = 'another value i want to pass as param'; return $data; }Right:<?php public function myDataProvider() { $data = array(); $data[] = array('some value i want to pass as param'); $data[] = array('another value i want to pass as param'); return $data; }Weiterlesen: ReflectionException: Method PHPUnit_Framework_Warning::Warning() does not exi ...Kommentare: 0 -
Automatic pushing to a remote git-repository with etckeeper
08.11.2011 19:48
A simple way is just to use etckeeprs hooks and create a script which does the pushing after all /etc/etckeeper/post-install.d/60vcs-commit-push#!/bin/sh set -e git push origin master
And don't forgetchmod +x /etc/etckeeper/post-install.d/60vcs-commit-push
Weiterlesen: Automatic pushing to a remote git-repository with etckeeperKommentare: 0 -
Identifier "request_context" is not defined with silex
08.11.2011 19:48
If you ever receive a message like:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Identifier "request_context" is not defined.' in phar:///.../vendor/silex/silex.phar/vendor/pimple/lib/Pimple.php on line 12
And it is not directly about the AsseticExtension in Silex-Extensions,it is probably because some of your code wants access to the url_generator - in my case it was my own Routing-Extension for twig. Weiterlesen: Identifier "request_context" is not defined with silexKommentare: 0 -
Netbeans, Symfony, Xdebug and the magical file_link_format
08.11.2011 19:48
Originally I was looking for a solution to get Chromium to open Files in Netbeans directly from symfony1 stack traces, because some time ago in a video I had see how it was done for other editors. Weiterlesen: Netbeans, Symfony, Xdebug and the magical file_link_formatKommentare: 0 -
Creating your own git aliases based on your needs
19.12.2010 11:56
If you want to create git aliases optimized for your daily work, you should start by analysing your shell logs to find out which git commands you use most of the time and create shortcuts for them:
Weiterlesen: Creating your own git aliases based on your needsKommentare: 0 -
Git, Aliases, Submodules and Symfony
19.12.2010 11:42
Some time ago i stumpled over Joel Perras (@jperras) blogentry Making Git Behave on twitter, covering the .gitconfig file and that was when I first found out about gits aliases and thanks to Joel I started to fill my gitconfig with more and more of them, speeding up my work with git und my working-environment for my mostly symfony based stuff.
Weiterlesen: Git, Aliases, Submodules and SymfonyKommentare: 0 -
RuntimeException: PHP Fatal error: 'You cannot serialize or unserialize PDOStatement instaces' in -:31 - PHPUnit - Process Isolation and Doctrine/PDO
03.10.2010 21:35
If you ever get this message:
RuntimeException: PHP Fatal error: Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDOStatement instances' in -:31 Stack trace: #0 [internal function]: PDOStatement->__sleep() #1 -(31): serialize(Array) #2 -(190): __phpunit_run_isolated_test() #3 {main} thrown in - on line 31Something with a doctrine/pdo went wrong in one of your tests, but since serialize does not work on pdo-classes, it prints out only this message.
Weiterlesen: RuntimeException: PHP Fatal error: 'You cannot serialize or unserialize PDOSt ...
If you want doctrines/PDOs message, run only this one test with process isolation turned off and you will get the error-message.
Really bad to debug on a continous-integration-system if it fails only there :)Kommentare: 1

Benjamin Steininger ist Webentwickler auf der Suche nach einem neuen Job und
photographiert sehr gerne. Er beschäftigt sich viel mit dem Internet, PHP, Symfony, Testing und hat einen