zikula / core

Zikula Core Framework
GNU Lesser General Public License v3.0
238 stars 66 forks source link

Replacement for ModUtil::available #3316

Closed Guite closed 7 years ago

Guite commented 7 years ago

We probably need a replacement API for ModUtil::available(). Because $this->kernel->getModule('...') does not check whether the module is activated or not. Thus, event listeners could be executed also for inactive modules.

shefik commented 7 years ago

It's also a problem if you have a module's route in the theme template file. When the module is inactive, it throws an error from the template.

Guite commented 7 years ago

Also if you follow https://github.com/zikula/core/blob/1.4/src/docs/Core-2.0/Themes/RouteUsage.md ?

shefik commented 7 years ago

Yeah, wrapping in the modAvailable throws the error.

craigh commented 7 years ago

no.

if the kernel has the module (or theme) loaded, it is because it is active.

https://github.com/zikula/core/blob/1.4/src/lib/Zikula/Bundle/CoreBundle/Bundle/Bootstrap.php#L57

we do not need a replacement.

there is no way to allow routes of inactive modules to be hardcoded into templates. This is why hardcoding things in a dynamic system is a bad idea.

shefik commented 7 years ago

An error can still be encountered, even if you follow the instructions at https://github.com/zikula/core/blob/1.4/src/docs/Core-2.0/Themes/RouteUsage.md.

Guite commented 7 years ago

Not for me, it works fine in a theme I am currently working on (env prod, debug true).

shefik commented 7 years ago

Try upgrading a module. When you go to Extensions to click upgrade on the desired module, the error gets thrown during that process.

craigh commented 7 years ago

it makes sense to me why https://github.com/zikula/core/blob/1.4/src/docs/Core-2.0/Themes/RouteUsage.md would not work - the template interpreter would try to generate the route without respect for the existence check. There is no way around that. The doc is wrong and should be removed.

shefik commented 7 years ago

Why not include in modAvailable, if a module is currently in the progress of being upgraded (when you actually click upgrade), then it is not available, until the api is complete?

craigh commented 7 years ago

see https://github.com/zikula/core/blob/6bf93fcab0dbed9255004bf9f76530bb74cb8365/src/app/ZikulaKernel.php#L139-L148