diff --git a/lib/internal/Magento/Framework/Module/Dir.php b/lib/internal/Magento/Framework/Module/Dir.php index 936fce3a046b7..688c7c43ac0e4 100644 --- a/lib/internal/Magento/Framework/Module/Dir.php +++ b/lib/internal/Magento/Framework/Module/Dir.php @@ -45,6 +45,12 @@ public function getDir($moduleName, $type = '') { $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName); + // An empty $type means it's getting the directory of the module itself. + if (empty($type) && !isset($path)) { + // Note: do not throw \LogicException, as it would break backwards-compatibility. + throw new \InvalidArgumentException("Module '$moduleName' is not correctly registered."); + } + if ($type) { if (!in_array($type, [ self::MODULE_ETC_DIR,