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

Wrong loading order of Modules generated by Core\Application #506

Closed
TiSiE opened this issue Nov 8, 2018 · 3 comments
Closed

Wrong loading order of Modules generated by Core\Application #506

TiSiE opened this issue Nov 8, 2018 · 3 comments
Assignees
Milestone

Comments

@TiSiE
Copy link
Member

TiSiE commented Nov 8, 2018

public static function generateModuleConfiguration($loadModules=[])
{
$modules = ArrayUtils::merge(
static::getRequiredModules(),
static::scanAdditionalModule()
);
$modules = ArrayUtils::merge($modules, $loadModules);
return $modules;
}

This will produce DependencyCheck errors, because additional modules will be loaded BEFORE the YAWIK modules.

In particular, when using yawik/JobsByMail, an exception occurs, because JobsByMail requires the Jobs module.

To get the ordering right, this might be a better approach:

    public static function generateModuleConfiguration($loadModules=[]) 
     { 
         $modules = array_merge( 
             static::getRequiredModules(), 
             $loadModules,
             static::scanAdditionalModule() 
         ); 

         return $modules; 
     } 
@TiSiE
Copy link
Member Author

TiSiE commented Nov 8, 2018

I forgot something:

if (strpos($addModule, '-') === 0) {
$remove = substr($addModule, 1);
$modules = array_filter($modules, function ($elem) use ($remove) {
return strcasecmp($elem, $remove);
});
} else {

This code was meant to allow to remove modules from the list prior to loading, but it is completely useless in this position, because the list of all modules is not generated at this point in the code execution.

@kilip
Copy link
Collaborator

kilip commented Nov 9, 2018

@TiSiE I will try to use DependencyIndicatorInterface in Organizations module, I hope this can make zf3 component installer making modules config in spesific order in yawik/standard:

/**
 * Bootstrap class of the organizations module
 */
class Module implements BootstrapListenerInterface, DependencyIndicatorInterface
{
    public function getModuleDependencies()
    {
        return [
            'Core',
            'Auth',
        ];
    }
}

I hope this can fix issue like #507 in future, because it will raise an error if Organization module loaded before Core or Auth module

I will fix that ordering issue in next pull request.

This code was meant to allow to remove modules from the list prior to loading, but it is completely useless in this position, because the list of all modules is not generated at this point in the code execution.

What about this issue? Can we delete this scanAdditionalModule function or you have any suggestion to fix this?

@TiSiE
Copy link
Member Author

TiSiE commented Nov 9, 2018

What about this issue? Can we delete this scanAdditionalModule function or you have any suggestion to fix this?

See yawik/standard#3

@TiSiE TiSiE added this to the v0.32 milestone Nov 15, 2018
@TiSiE TiSiE closed this as completed Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants