J4 Issue ? ?
avatar joeforjoomla
joeforjoomla
11 Sep 2017

Steps to reproduce the issue

Uninstall an extension on Joomla 4

Expected result

The script file is executed and the function 'uninstall' is called inside the class com_xxxxInstallerScript, when the function 'uninstall' is called it's still possible to use JText::_('...'); loading language files included under the component folder such as:
Joomla40/administrator/components/com_xxx/language/en-GB/en-GB.com_xxx.ini

Actual result

Files are already deleted at this stage compared to the current Joomla 3 and Joomla 2.5
Thus the JText won't translate strings anymore because it's no more possible to load language files already deleted. It works only if the component was using language files under:
Joomla40/administrator/language/en-GB/en-GB.com_xxx.ini

System information (as much as possible)

function uninstall($parent) { $lang = \Joomla\CMS\Factory::getLanguage(); $lang->load('com_xxx'); echo \JText::_('COM_XXX_UNINSTALL_SUCCESS' ); ....

Additional comments

avatar joeforjoomla joeforjoomla - open - 11 Sep 2017
avatar joomla-cms-bot joomla-cms-bot - change - 11 Sep 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Sep 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 11 Sep 2017
Category Language & Strings
avatar mbabker
mbabker - comment - 11 Sep 2017

Unless someone screwed up a merge, #16343 did not change the order things were processed; the uninstall hook is still long before the instruction to delete the extension files. Language files are even explicitly loaded as the last instruction in each adapter's setupUninstall method (which is before the uninstall hook).

avatar joeforjoomla
joeforjoomla - comment - 11 Sep 2017

I don't know what's going on... however to have it still working on Joomla 4 i had to move the code loading language files to the preflight() stage

function preflight($type, $parent) { $lang = \Joomla\CMS\Factory::getLanguage(); $lang->load('com_xxx'); }

avatar joeforjoomla
joeforjoomla - comment - 11 Sep 2017

No sorry my fault, this is not fixing the problem too
component_unistall

avatar mbabker
mbabker - comment - 11 Sep 2017

load() with only an extension parameter only loads files from the global language directory. If you're trying to load them from an extension directory, you have to pass the path. It's why you have multiple calls to the load() method in most places, like https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Component/ComponentHelper.php#L361

avatar joeforjoomla
joeforjoomla - comment - 11 Sep 2017

I tried that too, but nothing changes. Moreover this does not explain why the language files are not loaded anymore in Joomla 4... if the setupUninstall would work the following code should not be needed at all.

// Manage partial language translations $jLang = \Joomla\CMS\Factory::getLanguage(); $jLang->load('com_xxx', JPATH_COMPONENT_ADMINISTRATOR, 'en-GB', true, true); ì

avatar mbabker
mbabker - comment - 11 Sep 2017

Well without somebody debugging it we're just going to go back and forth with a "it's broken, this that and the other thing don't work" commentary ?

avatar joeforjoomla
joeforjoomla - comment - 11 Sep 2017

I'm just doing it... i think that the problem is that the '$this->element' property is 'null' during the setupUnistall

// Attempt to load the admin language file; might have uninstall strings $this->loadLanguage(JPATH_ADMINISTRATOR . '/components/' . $this->element);

avatar mbabker
mbabker - comment - 11 Sep 2017

Use $this->extension->element and it should be fine.

avatar joeforjoomla
joeforjoomla - comment - 11 Sep 2017

You got it ;)

That's the problem, changing the line 704 of /Joomla40staging/libraries/src/Installer/Adapter/ComponentAdapter.php

from:
$this->loadLanguage(JPATH_ADMINISTRATOR . '/components/' . $this->element);

to:
$this->loadLanguage(JPATH_ADMINISTRATOR . '/components/' . $this->extension->element);

fix the issue.

avatar joeforjoomla
joeforjoomla - comment - 11 Sep 2017

I guess this issue needs a PR

avatar franz-wohlkoenig franz-wohlkoenig - change - 11 Sep 2017
Status New Discussion
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 11 Apr 2019
Labels Added: J4 Issue ?
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 11 Apr 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 11 Apr 2019
Category Language & Strings
avatar Quy Quy - close - 16 Nov 2019
avatar Quy Quy - change - 16 Nov 2019
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2019-11-16 17:42:09
Closed_By Quy
avatar Quy
Quy - comment - 16 Nov 2019

Please test PR #27090


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17931.

Add a Comment

Login with GitHub to post a comment