Feature Architecture PR-6.3-dev Pending

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
16 May 2023

Summary of Changes

Our different extension types all have different ways how to find out their own name. A component, language and template could be named after a tag <element> in its manifest or by its name. A module will either use the <element> tag or read the first module attribute of a child of the <files> tag it can find. A file extension will always be named after its manifests filename, a plugin will require you to do the same as for modules, but does not support the <element> tag. Packages expect an element named <packagename>, which is not allowed to contain a pkg_ prefix. Libraries need an element named <libraryname>. Only half of that is documented here: https://docs.joomla.org/Manifest_files

This PR unifies that so that all extensions (except file) support the <element> tag and, if not present, will fall back to the name. The existing ways of naming an extension are kept and take precedence over this "new" behaviour:

Type Order in which the element is determined
Component, language, template <element>, <name> (unchanged)
Module <element>, module attribute in <files>, <name>
Plugin plugin attribute in <files>, <element>, <name>
Library <libraryname>, <element>, <name>
Package <packagename>, <element>, <name>. The pkg_ prefix is only added if it is not already there
File name of the manifest file (unchanged)

All results are now run through InputFilter::clean().

Behaviour changes

  • Plugins, libraries, packages and file extensions now use the same filter as components, languages and templates (cmd and lowercase). Before, the plugin attribute, <libraryname> and the manifest name of a file extension were used as written, and <packagename> was filtered but not lowercased. An extension whose name contains uppercase letters therefore gets a lowercase element after this PR.
  • <packagename>pkg_example</packagename> results in pkg_example instead of pkg_pkg_example.
  • A plugin without a plugin attribute used to be installed with an empty element directly into its group folder, a module without <element> and module attribute failed to install. Both are now named after <element> or <name>.

Testing Instructions

Create the test extensions below. Each one is a folder with the given .xml manifest and an index.html (the content does not matter, e.g. <!DOCTYPE html><title></title>), zipped so that the manifest is at the top level of the zip. Install each zip in System > Install > Extensions > Upload Package File.

After each install check the element in the database:

SELECT extension_id, name, type, element, folder FROM #__extensions WHERE name LIKE 'Element test%';

and check that the files are where the element says (see the expected results). Then uninstall the extension in System > Manage > Extensions and check that the files, the folder and, for libraries, packages and file extensions, the manifest in administrator/manifests/ are gone.

1. Plugin with a plugin attribute

elementtest1.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="system" method="upgrade">
	<name>Element test 1</name>
	<version>1.0.0</version>
	<files>
		<filename plugin="elementtest1">index.html</filename>
	</files>
</extension>
2. Plugin with only an <element> tag

[!WARNING]
Only install this plugin with the PR applied. Without the PR it is installed with an empty element directly into plugins/system, and uninstalling it deletes the whole plugins/system folder.

elementtest2.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="system" method="upgrade">
	<name>Element test 2</name>
	<element>elementtest2</element>
	<version>1.0.0</version>
	<files>
		<filename>index.html</filename>
	</files>
</extension>
3. Plugin with uppercase letters in the plugin attribute

elementtest3.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="system" method="upgrade">
	<name>Element test 3</name>
	<version>1.0.0</version>
	<files>
		<filename plugin="ElementTest3">index.html</filename>
	</files>
</extension>
4. Module with an <element> tag and a different module attribute

mod_elementtest4.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="module" client="site" method="upgrade">
	<name>Element test 4</name>
	<element>mod_elementtest4</element>
	<version>1.0.0</version>
	<files>
		<filename module="mod_elementtest4_legacy">index.html</filename>
	</files>
</extension>
5. Module with only a module attribute

mod_elementtest5.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="module" client="site" method="upgrade">
	<name>Element test 5</name>
	<version>1.0.0</version>
	<files>
		<filename module="mod_elementtest5">index.html</filename>
	</files>
</extension>
6. Library

elementtest6.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="library" method="upgrade">
	<name>Element test 6</name>
	<libraryname>elementtest6</libraryname>
	<version>1.0.0</version>
	<files>
		<filename>index.html</filename>
	</files>
</extension>
7. Package, with and without the pkg_ prefix

Put the zip of test 1 as plg_system_elementtest1.zip next to the manifest. There is no index.html in this package.

pkg_elementtest7.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="package" method="upgrade">
	<name>Element test 7</name>
	<packagename>elementtest7</packagename>
	<version>1.0.0</version>
	<files>
		<file type="plugin" id="elementtest1" group="system">plg_system_elementtest1.zip</file>
	</files>
</extension>

Install and uninstall it, then change the line to <packagename>pkg_elementtest7</packagename>, zip it again and install it again.

8. File extension

Put the index.html into a subfolder files.

files_elementtest8.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="file" method="upgrade">
	<name>Element test 8</name>
	<version>1.0.0</version>
	<fileset>
		<files folder="files" target="media/elementtest8">
			<filename>index.html</filename>
		</files>
	</fileset>
</extension>

Regression test
Before applying the PR, install a few existing extensions of different types, for example from the JED. Apply the PR, install the same versions again as an update and uninstall them. Also use System > Discover with an extension whose files were copied into the site manually.

Actual result BEFORE applying this Pull Request

  1. element = elementtest1, files in plugins/system/elementtest1.
  2. Not to be tested without the PR (see the warning above). The plugin would be installed with an empty element directly into plugins/system.
  3. element = ElementTest3, files in plugins/system/ElementTest3.
  4. element = mod_elementtest4, files in modules/mod_elementtest4.
  5. element = mod_elementtest5, files in modules/mod_elementtest5.
  6. element = elementtest6, files in libraries/elementtest6, manifest administrator/manifests/libraries/elementtest6.xml.
  7. element = pkg_elementtest7, manifest administrator/manifests/packages/pkg_elementtest7.xml. With the prefix in the manifest, the element is pkg_pkg_elementtest7.
  8. element = files_elementtest8, files in media/elementtest8, manifest administrator/manifests/files/files_elementtest8.xml.

All extensions except test 2 can be uninstalled completely.

Expected result AFTER applying this Pull Request

  1. Unchanged: element = elementtest1, files in plugins/system/elementtest1.
  2. element = elementtest2, files in plugins/system/elementtest2.
  3. element = elementtest3, files in plugins/system/elementtest3 (lowercase, see the behaviour changes above).
  4. Unchanged: element = mod_elementtest4, the <element> tag still takes precedence over the module attribute.
  5. Unchanged: element = mod_elementtest5.
  6. Unchanged: element = elementtest6.
  7. element = pkg_elementtest7, both with and without the prefix in the manifest.
  8. Unchanged: element = files_elementtest8.

All extensions can be uninstalled completely, and the extensions from the regression test can be updated and uninstalled as before.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar joomla-cms-bot joomla-cms-bot - change - 16 May 2023
Category ⇒ Libraries
avatar Hackwar Hackwar - open - 16 May 2023
avatar Hackwar Hackwar - change - 16 May 2023
Status New ⇒ Pending
avatar Hackwar Hackwar - change - 16 May 2023
Labels Added: ?
avatar richard67
richard67 - comment - 17 May 2023

@Hackwar Unit tests are failing, see https://ci.joomla.org/joomla/joomla-cms/65798/1/10 :

There were 3 failures:

1) Joomla\Tests\Unit\Libraries\Cms\Installer\Adapter\ModuleAdapterTest::testgetElement1
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'somethingElse'
+'mod_somethingelse'

/drone/src/tests/Unit/Libraries/Cms/Installer/Adapter/ModuleAdapterTest.php:82

2) Joomla\Tests\Unit\Libraries\Cms\Installer\Adapter\ModuleAdapterTest::testgetElement2
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'somethingElse'
+'mod_somethingelse'

/drone/src/tests/Unit/Libraries/Cms/Installer/Adapter/ModuleAdapterTest.php:100

3) Joomla\Tests\Unit\Libraries\Cms\Installer\Adapter\ModuleAdapterTest::testgetElementFromElementTag
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'somethingElse'
+'mod_somethingelse'

/drone/src/tests/Unit/Libraries/Cms/Installer/Adapter/ModuleAdapterTest.php:123
avatar Hackwar Hackwar - change - 1 Jul 2023
Labels Added: Feature
avatar HLeithner
HLeithner - comment - 30 Sep 2023

This pull request has been automatically rebased to 5.1-dev.

avatar Hackwar Hackwar - change - 22 Mar 2024
Status Pending ⇒ Closed
Closed_Date 0000-00-00 00:00:00 ⇒ 2024-03-22 10:49:55
Closed_By ⇒ Hackwar
avatar Hackwar Hackwar - close - 22 Mar 2024
avatar Hackwar Hackwar - change - 22 Mar 2024
Status Closed ⇒ New
Closed_Date 2024-03-22 10:49:55 ⇒
Closed_By Hackwar ⇒
Labels Added: ?
avatar Hackwar Hackwar - change - 22 Mar 2024
Status New ⇒ Pending
avatar Hackwar Hackwar - reopen - 22 Mar 2024
avatar Hackwar Hackwar - change - 3 Apr 2024
Labels Removed: ?
avatar HLeithner
HLeithner - comment - 24 Apr 2024

This pull request has been automatically rebased to 5.2-dev.

avatar HLeithner HLeithner - change - 24 Apr 2024
Title
…
[5.0] Unifying InstallAdapter::getElement()
[5.2] Unifying InstallAdapter::getElement()
avatar HLeithner HLeithner - edited - 24 Apr 2024
avatar HLeithner
HLeithner - comment - 2 Sep 2024

This pull request has been automatically rebased to 5.3-dev.

avatar HLeithner HLeithner - change - 2 Sep 2024
Title
…
[5.2] Unifying InstallAdapter::getElement()
[5.3] Unifying InstallAdapter::getElement()
avatar HLeithner HLeithner - edited - 2 Sep 2024
avatar Hackwar Hackwar - change - 26 Nov 2024
Labels Added: ?
Removed: ?
avatar HLeithner
HLeithner - comment - 4 Mar 2025

This pull request has been automatically rebased to 6.0-dev.

avatar HLeithner HLeithner - change - 4 Mar 2025
Title
…
[5.3] Unifying InstallAdapter::getElement()
[6.0] Unifying InstallAdapter::getElement()
avatar HLeithner HLeithner - edited - 4 Mar 2025
avatar brianteeman
brianteeman - comment - 11 Apr 2025

Please provide test instructions

avatar Hackwar Hackwar - change - 7 Aug 2025
Labels Added: PR-6.0-dev
Removed: ?
avatar HLeithner
HLeithner - comment - 31 Aug 2025

This pull request has been automatically rebased to 6.1-dev.

avatar HLeithner HLeithner - change - 31 Aug 2025
Title
…
[6.0] Unifying InstallAdapter::getElement()
[6.1] Unifying InstallAdapter::getElement()
avatar HLeithner HLeithner - edited - 31 Aug 2025
avatar HLeithner
HLeithner - comment - 17 Mar 2026

This pull request has been automatically rebased to 6.2-dev.

avatar tecpromotion tecpromotion - change - 15 Apr 2026
Title
…
[6.1] Unifying InstallAdapter::getElement()
[6.2] Unifying InstallAdapter::getElement()
avatar tecpromotion tecpromotion - edited - 15 Apr 2026
avatar Hackwar Hackwar - change - 21 Oct 2026
Labels Added: PR-6.2-dev Architecture
Removed: PR-6.0-dev
avatar HLeithner
HLeithner - comment - 6 Nov 2026

This pull request has been automatically rebased to 6.3-dev. Joomla! 6.2 is now in feature freeze.

avatar HLeithner HLeithner - change - 11 Nov 2026
Title
…
[6.2] Unifying InstallAdapter::getElement()
[6.3] Unifying InstallAdapter::getElement()
avatar HLeithner HLeithner - edited - 11 Nov 2026
avatar joomla-cms-bot joomla-cms-bot - change - 11 Nov 2026
Category Libraries ⇒ Libraries Administration Installation Language & Strings Repository NPM Change
avatar Hackwar Hackwar - change - 20 Nov 2026
Labels Added: Language Change NPM Resource Changed PR-6.3-dev
Removed: PR-6.2-dev
avatar joomla-cms-bot joomla-cms-bot - change - 20 Nov 2026
Category Libraries Administration Installation Language & Strings Repository NPM Change ⇒ Libraries
avatar Hackwar Hackwar - change - 28 Nov 2026
Labels Removed: Language Change NPM Resource Changed
avatar Hackwar Hackwar - change - 28 Nov 2026
The description was changed
avatar Hackwar Hackwar - edited - 28 Nov 2026
avatar Hackwar
Hackwar - comment - 28 Nov 2026

I worked on this further and the PR should be ready to be tested.

Add a Comment

Login with GitHub to post a comment