Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment based local.xml merging #41

Closed
wants to merge 1 commit into from
Closed

Environment based local.xml merging #41

wants to merge 1 commit into from

Conversation

Vinai
Copy link
Contributor

@Vinai Vinai commented Jul 11, 2012

Support merging an additional local.xml file based on the value of
the MAGE_APPLICATION_ENV environment variable.
The name of the file will be built as follows:

'app/etc/local.' . $_SERVER['MAGE_APPLICATION_ENV'] . '.xml'

The value of the variable is checked to contain only letters,
characters, underscores and dashes.
The file will be merged after the regular local.xml file.

The background idea is described by Matthias Zeis at
#7

Support merging an additional local.xml file based on the value of
the MAGE_APPLICATION_ENV environment variable.
The name of the file will be built as follows:

'app/etc/local.' . $_SERVER['MAGE_APPLICATION_ENV'] . '.xml'

The value of the variable is checked to contain only letters,
characters, underscores and dashes.
The file will be merged after the regular local.xml file.

The background idea is described by Matthias Zeis at
#7
@mzeis
Copy link
Contributor

mzeis commented Jul 14, 2012

Thanks Vinai for the implementation.

I tested these scenarios successfully:

  • use a different adminhtml frontName
  • use a different database name

If somebody wants to try this, follow these steps:

  • clone Vinais repository (https://github.com/Vinai/magento2.git) and checkout branch local.xml-override
  • install Magento
  • disable caches (this one is important as the config will be cached)
  • add MAGE_APPLICATION_ENV to your vHost config or .htaccess
    • e.g. SetEnv MAGE_APPLICATION_ENV dev
    • If you use .htaccess, edit the file in the Magento root directory, not pub/.htaccess
  • add your environment local.xml (e.g. local.dev.xml) and override the settings you want to test

@magento-team
Copy link
Contributor

Instead of applying the proposed patch, we have implemented it in different way.

Most of modifications will be concentrated in loadBase() method. New algorithm:

  1. Scan app/etc directory for all files with .xml extension
  2. Merge all the found files, except local.xml, in alphabetical order
  3. If the local.xml is found – merge it after all the files
  4. If the configuration option (Mage_Core_Model_Config_Options) "local_config" is provided (originates from MAGE_LOCAL_CONFIG environment variable), assess if it matches pattern and load additional file:
  • Pattern: alphanumeric or dash or underscore, then "/", then again alphanumeric or dash or underscore, then ".xml"
  • The file will be loaded only if local.xml has been loaded. If local.xml doesn't exist, the file will not be loaded.
  • If the declared file not found, it will be skipped.

This change will be rolled out in one of next updates.
Thank you for the idea and actual suggested implementation.

@Vinai
Copy link
Contributor Author

Vinai commented Jul 28, 2012

Thank you for the detailed answer!
The patch isn't in the current version of github yet, is it?
I like the idea of MAGE_LOCAL_CONFIG to configure config options, but is it possible to specify an php array using, lets say apache mod_env?

magento-team added a commit that referenced this pull request Aug 2, 2012
* Refactored ACL for the backend
  * ACL resources
    * Strict configuration format, validated by XSD schema
    * ACL configuration relocation from `app/code/<pool>/<namespace>/<module>/etc/adminhtml.xml` to `app/code/<pool>/<namespace>/<module>/etc/adminhtml/acl.xml`
    * Renamed ACL resource identifiers according to the format `<namespace>_<module>::<resource>` throughout the system
      * Backend menu configuration requires to specify ACL resource identifier in the new format
      * Explicit declaration of ACL resources in `app/code/<pool>/<namespace>/<module>/etc/system.xml` instead of implicit relation by XPath
    * Migration tool `dev/tools/migration/acl.php` to convert ACL configuration from 1.x to 2.x
  * Declaration of ACL resource/role/rule loaders through the area configuration
    * Module `Mage_Backend` declares loader for ACL resources in backend area
    * Module `Mage_User` declares loaders for ACL roles and rules (relations between roles and resources) in backend area
  * Implemented integrity and legacy tests for ACL
* Fixed issues:
  * Losing qty and visibility information when importing products
  * Impossibility to reload captcha on backend
  * Temporary excluded from execution integration test `Mage_Review_Model_Resource_Review_Product_CollectionTest::testGetResultingIds()` and corresponding fixture script, which cause occasional `segmentation fault` (exit code 139)
* Refactored methods with high cyclomatic complexity:
  * `Mage_Adminhtml_Block_System_Store_Edit_Form::_prepareForm()`
  * `Mage_Adminhtml_Block_System_Config_Form::initForm()`
  * `Mage_Adminhtml_Block_System_Config_Form::initFields()`
* GitHub requests:
  * [#32](#32) -- fixed declaration of localization CSV files
  * [#35](#35) -- removed non-used `Mage_Core_Block_Flush` block
  * [#41](#41) -- implemented ability to extends `app/etc/local.xml` by specifying additional config file via `MAGE_LOCAL_CONFIG` environment variable
magento-team added a commit that referenced this pull request Aug 2, 2012
* Refactored ACL for the backend
  * ACL resources
    * Strict configuration format, validated by XSD schema
    * ACL configuration relocation from `app/code/<pool>/<namespace>/<module>/etc/adminhtml.xml` to `app/code/<pool>/<namespace>/<module>/etc/adminhtml/acl.xml`
    * Renamed ACL resource identifiers according to the format `<namespace>_<module>::<resource>` throughout the system
      * Backend menu configuration requires to specify ACL resource identifier in the new format
      * Explicit declaration of ACL resources in `app/code/<pool>/<namespace>/<module>/etc/system.xml` instead of implicit relation by XPath
    * Migration tool `dev/tools/migration/acl.php` to convert ACL configuration from 1.x to 2.x
  * Declaration of ACL resource/role/rule loaders through the area configuration
    * Module `Mage_Backend` declares loader for ACL resources in backend area
    * Module `Mage_User` declares loaders for ACL roles and rules (relations between roles and resources) in backend area
  * Implemented integrity and legacy tests for ACL
* Fixed issues:
  * Losing qty and visibility information when importing products
  * Impossibility to reload captcha on backend
  * Temporary excluded from execution integration test `Mage_Review_Model_Resource_Review_Product_CollectionTest::testGetResultingIds()` and corresponding fixture script, which cause occasional `segmentation fault` (exit code 139)
* Refactored methods with high cyclomatic complexity:
  * `Mage_Adminhtml_Block_System_Store_Edit_Form::_prepareForm()`
  * `Mage_Adminhtml_Block_System_Config_Form::initForm()`
  * `Mage_Adminhtml_Block_System_Config_Form::initFields()`
* GitHub requests:
  * [#32](#32) -- fixed declaration of localization CSV files
  * [#35](#35) -- removed non-used `Mage_Core_Block_Flush` block
  * [#41](#41) -- implemented ability to extends `app/etc/local.xml` by specifying additional config file via `MAGE_LOCAL_CONFIG` environment variable
magento-team pushed a commit that referenced this pull request Jan 23, 2015
MAGETWO-31053: M2 GitHub Update (version 0.42.0-beta4)
@stevieyu stevieyu mentioned this pull request Apr 3, 2015
@chrom chrom mentioned this pull request Oct 7, 2015
okorshenko pushed a commit that referenced this pull request Oct 27, 2015
magento-engcom-team pushed a commit that referenced this pull request May 30, 2021
@FabXav FabXav mentioned this pull request Oct 11, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants