No Code Attached Yet
avatar imanickam
imanickam
30 Oct 2021

Steps to reproduce the issue

(a) Log into administrator back-end
(b) Install the French language
(c) Go to screen "Extensions: Manage" (System => Manage -> Extensions)
(d) Select the extension that has the Name as "French (fr-FR)", Location as "Site", and Type as "Language"
(e) Press the button "Uninstall"

Note:
French language has been used for illustration only. This behavior is exhibited in all the language packs.

Expected result

The error message should contain the full name of the extension
The French (fr-FR) extension is part of a package which does not allow individual extensions to be uninstalled.

Actual result

The Frenchfr-FR extension is part of a package which does not allow individual extensions to be uninstalled.

screen shot 2021-10-30 at 08 41 04

Notice that the spaces and parenthesis are removed from the extension name. You can notice this behavior in the following example as well.

screen shot 2021-10-30 at 08 41 49

System information (as much as possible)

Joomla! 4.0.4

Additional comments

This may not be applicable only to language packs. This behavior would be exhibited in any extension that is a part of a package where the tag

<blockChildUninstall>true</blockChildUninstall>

is available in the package's xml file.

avatar imanickam imanickam - open - 30 Oct 2021
avatar imanickam imanickam - change - 30 Oct 2021
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 30 Oct 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 30 Oct 2021
avatar infograf768
infograf768 - comment - 31 Oct 2021

Confirmed.

avatar infograf768
infograf768 - comment - 31 Oct 2021

In fact, the extension language name is saved a such in the db.
Screen Shot 2021-10-31 at 10 04 36

Screen Shot 2021-10-31 at 10 07 00

Screen Shot 2021-10-31 at 10 07 40

EDIT/NOTE: same behavior in 3.x

avatar infograf768
infograf768 - comment - 31 Oct 2021

This comes from this code in the language adapter

$this->name = InputFilter::getInstance()->clean((string) $this->getManifest()->name, 'cmd');

->clean the manifest name takes off the parenthesis and spaces.

avatar richard67
richard67 - comment - 31 Oct 2021

No idea why the "cmd" filter is used here. Maybe we should use "string"? Or "html"?

avatar HLeithner
HLeithner - comment - 31 Oct 2021

IIRC the name is parsed by JText that's the reason why spaces are not allowed, normally a extension name is com_xxx and in the component ini you have a language string com_xxx="The XXX component" I would expect the same is true for language packages.

avatar imanickam
imanickam - comment - 1 Nov 2021

Thanks for looking into this.

FYI - The same behavior is exhibited in 3.10 as well.

avatar infograf768
infograf768 - comment - 1 Nov 2021

IIRC the name is parsed by JText that's the reason why spaces are not allowed, normally a extension name is com_xxx and in the component ini you have a language string com_xxx="The XXX component" I would expect the same is true for language packages.

Languages names (for clients) are an exception. Indeed they pass through Text::_() as all extensions when displayed in the Extensions Manager, but they should never be translated but always presented in English.
The best demonstration is English (en-GB) which in the db is presented in full. Package and clients.

The other languages package names are also saved in db in full. No clean there but only the manifest name. Only the client languages are not.

Screen Shot 2021-11-01 at 05 51 19

In the Extensions Manager,
Screen Shot 2021-11-01 at 05 52 36

Text::_() is not used in the Installed languages view and it is fine. (Italiano is a wrong name. Should be Italian...)

Screen Shot 2021-11-01 at 06 03 38

Therefore, there is no reason to install client languages with cmd.

I tested changing cmd to string and it now works fine.
$this->name = InputFilter::getInstance()->clean((string) $this->getManifest()->name, 'string');

Screen Shot 2021-11-01 at 06 11 53

avatar richard67
richard67 - comment - 2 Nov 2021

Hmm, if we change the filter for the name and the names are stored in database after filtering, then after changing the filter to "string" the name will not match anymore to what is stored in database. So it would need to fix the values in database with values from the manifests for all extensions of whichever type when updating from a version without the change to a version with the change from a potential fix.

avatar infograf768
infograf768 - comment - 2 Nov 2021

I do not think so.

  1. It concerns only the LanguageAdapter.php i.e. languages extensions
  2. We would also have to change 'cmd' to 'string' in the update method.
  3. I tested.

I installed the French pack https://downloads.joomla.org/language-packs/translations-joomla4/downloads/joomla4-french/4-0-3-1

then I modified the LanguageAdapter to use 'string' and went to install languages: it proposed pack 4.0.4.1.
All went fine.

There is a good reason for that, the adapter does not check for equal names but only tag, type and client

// Update an entry to the extension table
		$row = Table::getInstance('extension');
		$eid = $row->find(array('element' => $this->tag, 'type' => 'language', 'client_id' => $clientId));

		if ($eid)
		{
			$row->load($eid);
		}
		else
		{
			// Set the defaults

			// There is no folder for language
			$row->set('folder', '');
			$row->set('enabled', 1);
			$row->set('protected', 0);
			$row->set('access', 0);
			$row->set('client_id', $clientId);
			$row->set('params', $this->parent->getParams());
		}

		$row->set('name', $this->name);

$this->name is taken from a bit above in the code. It is the new pack manifest:

// Get the language name
		// Set the extensions name
		$name = (string) $this->getManifest()->name;
		$name = InputFilter::getInstance()->clean($name, 'string'); // which I just changed to `string`
		$this->name = $name;

As for English it is already fine as English (en-GB) in the db.

avatar richard67
richard67 - comment - 6 Nov 2021

Pull request for 3.10 is #35980 . Please test. Later when it has been merged, it will go into 4.0-dev with the next regular upmerge after that.

But maybe I make another PR with the same change for 4.0-dev for human testers.

avatar richard67 richard67 - change - 6 Nov 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-11-06 16:58:11
Closed_By richard67
avatar richard67 richard67 - close - 6 Nov 2021
avatar richard67
richard67 - comment - 6 Nov 2021

Pull request for Joomla 4 is #35981 .

@imanickam Please test. If you can test with both 3.10.x and 4.0.y, test #35980 , too . Thanks in advance.

Closing as having a pull request for each 3.10 and 4.0.

Add a Comment

Login with GitHub to post a comment