Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Allow module dependencies to not be "hard" dependencies. #19

wants to merge 1 commit into from

3 participants


It would sometimes be very helpful to use the module "depends" feature to force ordering of module loading, without explicitly requiring the other modules. For example, if module A breaks when module B is loaded after module A, but A works fine if B is not present, then it would be nice for module A to have a "soft" dependency on module B. That is, do not require module B to be loaded, but if it is loaded, make sure module B is loaded first.

In the xml this would look like:

        <Module_B type="soft" />
        <Module_C />

Although this is a pull request I understand that you may want different attribute naming, xml semantics, etc. Please let me know what you think or if you want me to make any changes. Thanks!


Oh, forgot to mention the commit is not tested.. :-o


The feature has been implemented in the development repository along with tests, it will become available with the next Github updates.

@mage2-team mage2-team referenced this pull request from a commit
@mage2-team mage2-team Update as of 6/7/2012
* Fixed various crashes of visual design editor
* Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels
* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework
* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests
* Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code)
* Github requests:
** [#19](#19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests

Closing request as implemented. Thank you for the suggestion.

@mage2-team mage2-team closed this
This was referenced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 4 deletions.
  1. +14 −4 app/code/core/Mage/Core/Model/Config.php
18 app/code/core/Mage/Core/Model/Config.php
@@ -36,6 +36,9 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base
+ const DEPENDS_TYPE_SOFT = 'soft';
+ const DEPENDS_TYPE_HARD = 'hard';
* Flag which allow use cache logic
@@ -800,7 +803,11 @@ protected function _loadDeclaredModules()
$depends = array();
if ($moduleNode->depends) {
foreach ($moduleNode->depends->children() as $depend) {
- $depends[$depend->getName()] = true;
+ if ($depend->getAttribute('type') == self::DEPENDS_TYPE_SOFT) {
+ $depends[$depend->getName()] = self::DEPENDS_TYPE_SOFT;
+ } else {
+ $depends[$depend->getName()] = self::DEPENDS_TYPE_HARD;
+ }
$moduleDepends[$moduleName] = array(
@@ -844,8 +851,11 @@ protected function _sortModuleDepends($modules)
foreach ($modules as $moduleName => $moduleProps) {
$depends = $moduleProps['depends'];
- foreach ($moduleProps['depends'] as $depend => $true) {
- if ($moduleProps['active'] && ((!isset($modules[$depend])) || empty($modules[$depend]['active']))) {
+ foreach ($moduleProps['depends'] as $depend => $dependType) {
+ if ( $moduleProps['active']
+ && $dependType == self::DEPENDS_TYPE_HARD
+ && ((!isset($modules[$depend])) || empty($modules[$depend]['active']))
+ ) {
Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" requires module "%2$s".', $moduleName, $depend)
@@ -869,7 +879,7 @@ protected function _sortModuleDepends($modules)
$definedModules = array();
foreach ($modules as $moduleProp) {
- foreach ($moduleProp['depends'] as $dependModule => $true) {
+ foreach ($moduleProp['depends'] as $dependModule => $dependType) {
if (!isset($definedModules[$dependModule])) {
Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" cannot depend on "%2$s".', $moduleProp['module'], $dependModule)
Something went wrong with that request. Please try again.