- Issue created by @lrwebks
- 🇩🇪Germany lrwebks Porta Westfalica
Update: This issue might be very close to fixing the problem: #2808063: LibraryDiscoveryParser::buildByExtension() doesn't validate that extensions exist →
While working on a different issue for a module that requires to know whether a given library exists via the Library Discovery Service, I stumbled upon this piece of code in the buildByExtension()
function of LibraryDiscoveryParser.php
:
if ($extension === 'core') {
$path = 'core';
$extension_type = 'core';
}
else {
if ($this->moduleHandler->moduleExists($extension)) {
$extension_type = 'module';
}
else {
$extension_type = 'theme';
}
$path = $this->extensionPathResolver->getPath($extension_type, $extension);
}
I don't think that the extension should just default to 'theme' if the extension is not 'core' and the module does not exist as this throws lots of User warning: The following theme is missing from the file system:
errors that a custom module should not have to work its way around when simply trying to search for libraries and not for themes.
Use the getLibraryByName()
function of the Library Discovery service with a library extension that is invalid, and instead of getting the false
that we hoped for, receive theme-related errors.
The best way to solve this in my opinion would just be to have a check whether the theme exists and if it does not, return false
should be the last resort instead of defaulting to theme search and throwing errors. This would work since the function returns false
anyway if the given library is not found, e.g. in core.
Otherwise,
#2231385: Verify that the library files exist →
looks like a promising step towards a clean solution, so we could integrate the isLibraryValid()
function from that later?
Active
11.0 🔥
Update: This issue might be very close to fixing the problem: #2808063: LibraryDiscoveryParser::buildByExtension() doesn't validate that extensions exist →