2

I'm creating backup copies of my local.xml files in the app/etc. directory for the different sandbox environments I use (e.g. localhost.local.xml, sandbox.localhost.xml, production.localhost.xml). I do this out of convenience so they are retained in my git repository.

However, I find that sometimes Magento picks up the wrong database configuration for the environment, not from the local.xml.

1 Answer 1

5

I discovered the hard way that renaming the .xml files in the app/etc directory by prefixing them (but leaving the .xml extension) was causing problems with my Magento site.

It turns out that Magento loads all *.xml files from the app/etc directory, not just global.xml and local.xml. See function loadBase() in app/code/core/Model/Config.php

The .xml files are then processed in the order returned by glob (which I believe is alphabetical by default). This means that local.xml values overriding global.xml values is just a side-effect of the fact that global.xml is returned eariler in the list.

The problem is, if you have extra files, like I did, the files that come later in the alphabet may override your settings in local.xml ! I've learned my lesson and no longer leave the trailing .xml on my backup files in that app/etc directory anymore.

Hope this is useful to others debugging mysterious database connection issues!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.