Installing component and module at the same time causes install error #941

Closed
opened 2022-07-27 16:21:16 +00:00 by SimonvanDoorne · 5 comments
Member

Steps to reproduce the issue

  1. create component
  2. create module
  3. add module to component
  4. compile component
  5. use button 'Install all above extensions on this Joomla! website'

Expected result

Install of both component and module

Actual result

Error "com_COMPONENTNAMEInstallerScript::preflight() must be an instance of Joomla\CMS\Installer\Adapter\ComponentAdapter, instance of Joomla\CMS\Installer\Adapter\ModuleAdapter given"
image

System information (as much as possible)

  • OS Name & Version:
  • MySql Version:
  • Apache Version:
  • PHP Version: 7.4
  • Joomla Version: 3.10.10
  • JCB Version: 3.4.1
  • Browser: Firefox

Additional comments

I blocked out the exact name of component in the image but that should not have an effect on the issue. Installing the component and module by themself works fine, it's just when you try to install both it goes wrong

### Steps to reproduce the issue 1) create component 2) create module 3) add module to component 4) compile component 5) use button 'Install all above extensions on this Joomla! website' ### Expected result Install of both component and module ### Actual result Error "com_COMPONENTNAMEInstallerScript::preflight() must be an instance of Joomla\CMS\Installer\Adapter\ComponentAdapter, instance of Joomla\CMS\Installer\Adapter\ModuleAdapter given" ![image](/attachments/f3c4f4bc-1e1c-4fd0-bf34-f197d6865e68) ### System information (as much as possible) - OS Name & Version: - MySql Version: - Apache Version: - PHP Version: 7.4 - Joomla Version: 3.10.10 - JCB Version: 3.4.1 - Browser: Firefox ### Additional comments I blocked out the exact name of component in the image but that should not have an effect on the issue. Installing the component and module by themself works fine, it's just when you try to install both it goes wrong
Owner

I think this is still an error related to this issue, can you try the tmp fix... and let me know?

I think this is still an error related to this [issue](https://git.vdm.dev/joomla/Component-Builder/issues/868), can you try the tmp fix... and let me know?
Author
Member

That does indeed fix the issue. I can try to debug this and make a pull request if that's gonna save you some time?

That does indeed fix the issue. I can try to debug this and make a pull request if that's gonna save you some time?
Owner

Your welcome, but I can tell you what is wrong.... and I kinda know how to fix it...

So what goes wrong is the install class for the plugin does not get build correctly so if we add a field... in the GUI then the class get build.

So for the module we have to just from a_Get.php line-9737 we need to add the following... as a test:

// add PHP in module install
$module->add_install_script = true;

So for the plugin we have to just from a_Get.php line-10644 we need to add the following... as a test:

// add PHP in plugin install
$plugin->add_install_script = true;

I think this will resolve the issue, but I have not had time to test this.

Should that not work, there is two more things to try... let me know.

Your welcome, but I can tell you what is wrong.... and I kinda know how to fix it... So what goes wrong is the install class for the plugin does not get build correctly so if we add a field... in the GUI then the class get build. So for the module we have to just from [a_Get.php line-9737](https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/admin/helpers/compiler/a_Get.php#L9737) we need to add the following... as a test: ```php // add PHP in module install $module->add_install_script = true; ``` So for the plugin we have to just from [a_Get.php line-10644](https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/admin/helpers/compiler/a_Get.php#L10644) we need to add the following... as a test: ```php // add PHP in plugin install $plugin->add_install_script = true; ``` I think this will resolve the issue, but I have not had time to test this. Should that not work, there is two more things to try... let me know.
Author
Member

When i set add_install_script to true it indeed installs correctly. Thanks!

I looked a bit further and in f_Infusion.php line 2390 there is this code:

// only add install script if needed
if ($module->add_install_script)
{
	// INSTALLCLASS
	$this->fileContentDynamic[$module->key][$this->hhh
	. 'INSTALLCLASS' . $this->hhh]
		= $this->getExtensionInstallClass($module);
}

The same goes for the plugin install (but that one is on line 2453). Is this something you want to add to the next update yourself or would you like me to make a pull request?

When i set add_install_script to true it indeed installs correctly. Thanks! I looked a bit further and in f_Infusion.php line 2390 there is this code: ``` // only add install script if needed if ($module->add_install_script) { // INSTALLCLASS $this->fileContentDynamic[$module->key][$this->hhh . 'INSTALLCLASS' . $this->hhh] = $this->getExtensionInstallClass($module); } ``` The same goes for the plugin install (but that one is on line 2453). Is this something you want to add to the next update yourself or would you like me to make a pull request?
Owner

I just needed someone to test that... if it works then I can make the change, no problem.

I just needed someone to test that... if it works then I can make the change, no problem.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#941
No description provided.