-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix - loadModule reinitializes modules if the module has already been… #34
base: 2.12.x
Are you sure you want to change the base?
Conversation
… loaded laminas#32 Signed-off-by: Sebastian Hopfe <[email protected]>
… loaded laminas#32 Signed-off-by: Sebastian Hopfe <[email protected]>
Signed-off-by: Sebastian Hopfe <[email protected]>
any review possible? |
@Xerkus |
Hi. Is there anything holding this fix back? The |
@froschdesign - ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the current release branch for this bugfix: 2.14.x
public function testModuleLoadingBehaviorWithModuleClassStrings() | ||
{ | ||
$moduleManager = new ModuleManager(['SomeModule'], $this->events); | ||
$this->defaultListeners->attach($this->events); | ||
$modules = $moduleManager->getLoadedModules(); | ||
self::assertSame(0, count($modules)); | ||
$modules = $moduleManager->getLoadedModules(true); | ||
self::assertSame(1, count($modules)); | ||
$moduleManager->loadModules(); // should not cause any problems | ||
$moduleManager->loadModule(Module::class); // should not cause any problems | ||
$modules = $moduleManager->getLoadedModules(true); // BarModule already loaded so nothing happens | ||
self::assertSame(1, count($modules)); | ||
} | ||
|
||
public function testModuleLoadingBehaviorWithModuleClassStringsVersion2() | ||
{ | ||
$moduleManager = new ModuleManager([Module::class], $this->events); | ||
$this->defaultListeners->attach($this->events); | ||
$modules = $moduleManager->getLoadedModules(); | ||
self::assertSame(0, count($modules)); | ||
$modules = $moduleManager->getLoadedModules(true); | ||
self::assertSame(1, count($modules)); | ||
$moduleManager->loadModules(); // should not cause any problems | ||
$moduleManager->loadModule('SomeModule'); // should not cause any problems | ||
$modules = $moduleManager->getLoadedModules(true); // BarModule already loaded so nothing happens | ||
self::assertSame(1, count($modules)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a data provider here and add some blank lines to break the wall of code / text.
* @param string $moduleName | ||
* @return string | ||
*/ | ||
private function getVerifiedModuleName($moduleName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the types to the method because it is private and supported.
Description
As descripted in #32 . there is an bug when loading a module with another loading name. there are currently 3 ways to load the same module via the module manager. the following options are available:
if you use method 1 (namespace) and method 2 (class string) for the same module in an application, it will be loaded twice and reset the previous settings.
this pull request fixes the false behavior and prevents a module from being loaded twice.
fixes #32