For last few days I’m experiencing following issue with doctrine – since I am not allowed to paste any source code, I’ll try to describe briefly:
I am using doctrine orm and I need to add a new column to an existing table in DB – mapping between DB and entities is done via xml mapping file – here are the steps I’ve proceeded:
- I’ve added into the entity file – let’s call it Entity.php – new field for that newColumn
- I’ve added info about this newColumn into the XML mapping file as new XML element ‘field’
- I’ve executed doctrine command to change the schema of the DB based on edited mapping file
- I’ve updated the query in EntityRepository.php file to include this new column.
When I then run the application, I am still getting this error:
[Semantical Error] Error: Class Entity.php has no field or association named newColumn
So, if I am understanding this properly, it is saying that in the Entity.php is not field newColumn to which should be the new DB column mapped.
But that is not the case, since it was the very first step I’ve done.
I’ve already tried this:
- Checked there is no typo in name of the newColumn across all files
- Checked the field in Entity.php has proper access modifiers – i.e. it is not private
- Cache was cleared for the case that some bad version of Entity.php was stored
- I’ve restarted apache server which the application runs on
Advertisement
Answer
Check your metadata cache. If you’re using some external caching mechanism (like Memcached or xcache) it’s probably shared across your vhosts. If one vhost populates the cache with its own mapping metadata (after apache restart), second vhost just uses it and doesn’t care about different .dcm.xml mappings.
If it’s your development server/vhost, it’s usually much better to disable ORM caching at all (config/autoload/database.local.php).