Skip to content

Commit bb33139

Browse files
authored
[6.0] Installer: Remove dependency on Adapter class (#43792)
* Installer: Remove dependency on Adapter class * Update ExtensionInstallCommand.php * Fixing database injection
1 parent 98cc9b0 commit bb33139

File tree

4 files changed

+163
-55
lines changed

4 files changed

+163
-55
lines changed

administrator/components/com_joomlaupdate/src/Model/UpdateModel.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,6 @@ public function finaliseUpgrade()
923923
$installer->extension = new \Joomla\CMS\Table\Extension($db);
924924
$installer->extension->load(ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id);
925925

926-
$installer->setAdapter($installer->extension->type);
927-
928926
$installer->setPath('manifest', JPATH_MANIFESTS . '/files/joomla.xml');
929927
$installer->setPath('source', JPATH_MANIFESTS . '/files');
930928
$installer->setPath('extension_root', JPATH_ROOT);

libraries/src/Console/ExtensionInstallCommand.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Joomla\CMS\Installer\Installer;
1313
use Joomla\CMS\Installer\InstallerHelper;
1414
use Joomla\Console\Command\AbstractCommand;
15+
use Joomla\Database\DatabaseAwareTrait;
16+
use Joomla\Database\DatabaseInterface;
1517
use Symfony\Component\Console\Input\InputInterface;
1618
use Symfony\Component\Console\Input\InputOption;
1719
use Symfony\Component\Console\Output\OutputInterface;
@@ -28,6 +30,8 @@
2830
*/
2931
class ExtensionInstallCommand extends AbstractCommand
3032
{
33+
use DatabaseAwareTrait;
34+
3135
/**
3236
* The default command name
3337
*
@@ -62,6 +66,20 @@ class ExtensionInstallCommand extends AbstractCommand
6266
*/
6367
public const INSTALLATION_SUCCESSFUL = 0;
6468

69+
/**
70+
* Command constructor.
71+
*
72+
* @param DatabaseInterface $db The database
73+
*
74+
* @since __DEPLOY_VERSION__
75+
*/
76+
public function __construct(DatabaseInterface $db)
77+
{
78+
parent::__construct();
79+
80+
$this->setDatabase($db);
81+
}
82+
6583
/**
6684
* Configures the IO
6785
*
@@ -130,7 +148,8 @@ public function processPathInstallation($path): bool
130148
return false;
131149
}
132150

133-
$jInstaller = Installer::getInstance();
151+
$jInstaller = new Installer();
152+
$jInstaller->setDatabase($this->getDatabase());
134153
$result = $jInstaller->install($package['extractdir']);
135154
InstallerHelper::cleanupInstall($tmpPath, $package['extractdir']);
136155

@@ -163,6 +182,7 @@ public function processUrlInstallation($url): bool
163182
}
164183

165184
$jInstaller = new Installer();
185+
$jInstaller->setDatabase($this->getDatabase());
166186
$result = $jInstaller->install($package['extractdir']);
167187
InstallerHelper::cleanupInstall($path, $package['extractdir']);
168188

0 commit comments

Comments
 (0)