User tests: Successful: Unsuccessful:
Pull Request for Issue # .
Since #32633 J4 (non legacy) Modules don't have a module.php
file in their root folder
and thus it's impossible to install a module that uses namespace, check the existing code:
joomla-cms/libraries/src/Installer/Adapter/ModuleAdapter.php
Lines 337 to 356 in 2c30264
To mitigate this in the easiest possible way I propose to require (for the J4 native modules, not the legacy) one field in the XML: eg <element>mod_wow</element>
;
You could test this in 2 different ways:
mod_quickicon
administrator/mopdules/mod_quickicon
to a folder outside of the Joomla folderfile mod_quickicon.php doesn't exist
)<filename module="mod_quickicon">mod_quickicon.php</filename>
and adding after line 3 <element>mod_quickicon</element>
then zip the contents of the folder and try againAlternative you can download https://jinvalidate.netlify.app/dist/j4/mod_invalidatecache_0.0.6.zip
and observe that the module installs correctly
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Please update the method to be this.
This employs "return early" pattern.
This code has been fully tested with the new Unit Test you can use in PR #33260 - the tests pass before and after this refactoring.
/**
* Get the filtered extension element from the manifest
*
* @param string $element Optional element name to be converted
*
* @return string|null The filtered element
*
* @since 3.4
*/
public function getElement($element = null)
{
if ($element)
{
return $element;
}
// Joomla 4 Module.
if ((string) $this->getManifest()->element)
{
return (string) $this->getManifest()->element;
}
if (!\count($this->getManifest()->files->children()))
{
return $element;
}
foreach ($this->getManifest()->files->children() as $file)
{
if ((string) $file->attributes()->module)
{
// Joomla 3 (legacy) Module.
return strtolower((string) $file->attributes()->module);
}
}
return $element;
}
Thanks @PhilETaylor code updated
I have tested this item
I've tested with use of https://jinvalidate.netlify.app/dist/j4/mod_invalidatecache_0.0.6.zip . Without this PR, there is an error when trying to install the module. With the PR, there is no error, and the module is installed. Other modules can still be installed, too.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-04-23 15:22:56 |
Closed_By | ⇒ | chmst | |
Labels |
Added:
?
|
Thanks!
BTW this should be a release blocker