Same query runs twice with SoftDeleteable behavior

Today i hit a relatively simple problem where my tests would issue the same query twice and thus return the same result although the result should have been different. The problem is related to the use of the STOF/Doctrine-Bundle-Extension which adds a listener to add a condition to the query i build using the softdeleteable behavior. The problem with this is that if you query the first part of the query, it means that next time you try to get the same query, the query is not updated with the latest timeaware parameter and thus:

SELECT pi FROM PersonalizableItem pi WHERE token = :token

gets changed to

SELECT pi FROM PersonalizableItem pi WHERE token = :token AND (deletedAt is null or deletedAt <= 'some date')

This second query gets cached so the time in “some date” doesn’t change and thus, even if you deleted the item and try to query it again (for testing purposes in my case) then the result is incorrect and your test fails.

To fix, this, substitute the query cache currently used in your application with a VoidCache and this will prevent the query caching from occuring. Obviously, you don’t want and usually don’t need this in the production context, but in a test context, it is very valid and often necessary for integration like tests.

self::$entityManager = static::getSharedKernel()->getContainer()->get('doctrine.orm.default_entity_manager');
self::$entityManager->getConfiguration()->setQueryCacheImpl(new VoidCache());

Symfony 2 serializing nulls or not on demand

Symfony is pretty new to me and i’m learning new stuff everyday. Building this api where i work made me learn that sometimes you may want to have the null serialized and sometimes not. So by default, let’s say you activate it, when you want to deactivate it on the fly, the best way is just to turn on/off the null serialization strategy.


IMO, it’s best to simply always serialize nulls as not all end users will be able to deserialize missing properties or not. If a property is not set, it should still be serialized by default but with a null. It’s a matter of taste i guess, but tecnically speaking, i’d always do that!

A host only network interface you’re attempting to configure via DHCP already has a conflicting host only adapter

Using Vagrant on a new machine on Ubuntu 14.04 this morning cause me quite some trouble when doing a simple “vagrant up”. The message:

A host only network interface you’re attempting to configure via DHCP already has a conflicting host only adapter with DHCP enabled. The DHCP on this adapter is incompatible with the DHCP settings. Two host only network interfaces are not allowed to overlap, and each host only network interface can have only one DHCP server. Please reconfigure your host only network or remove the virtual machine using the other host only network.

This led me on a search to understand the problem and find the following simple answer, remove the DHCP server on the machine by doing:

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

Support a sick friend, buy a cool coder t-shirt!

One of my friend is sick with leukemia LAL a special form of leukemia that cannot be cured with standard medication. Sadly, that non-standard medication is not covered and she doesn’t have enough cash on hand to pay for it. She’s doomed unless we poll together.

I created a teespring campaign with a cool t-shirt for coders, all profits will go to her fund raising to help her pay for her treatment:

Thanks in advance!

Tips from a PHP expert, public speaker and trainer