fix - loadModule reinitializes modules if the module has already been… - #34
fix - loadModule reinitializes modules if the module has already been…#34nusphere wants to merge 3 commits into
Conversation
… loaded laminas#32 Signed-off-by: Sebastian Hopfe <sebastian.hopfe@milchundzucker.de>
… loaded laminas#32 Signed-off-by: Sebastian Hopfe <sebastian.hopfe@milchundzucker.de>
Signed-off-by: Sebastian Hopfe <sebastian.hopfe@milchundzucker.de>
|
any review possible? |
|
@Xerkus |
|
Hi. Is there anything holding this fix back? The |
|
@froschdesign - ping |
froschdesign
left a comment
There was a problem hiding this comment.
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.
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.
Add the types to the method because it is private and supported.
|
No matter how I look at this there is a BC break in any fix. It is incredibly brittle and was around for so long this way it is almost not worth fixing. |
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