From b4b6e2bd82e9573635322dce6b906c29cc5dd8c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 20 Apr 2024 22:16:58 +0200 Subject: [PATCH] Include RC iniset.php using async promise --- src/ExtensionInstaller.php | 61 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/ExtensionInstaller.php b/src/ExtensionInstaller.php index dff6d01..88295ce 100644 --- a/src/ExtensionInstaller.php +++ b/src/ExtensionInstaller.php @@ -47,16 +47,17 @@ public function getInstallPath(PackageInterface $package) public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { - // initialize Roundcube environment $this->setRoundcubemailInstallPath($repo); - if (!defined('INSTALL_PATH')) { - define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); - } - require_once INSTALL_PATH . 'program/include/iniset.php'; - - $this->rcubeVersionCheck($package); $postInstall = function () use ($package) { + // initialize Roundcube environment + if (!defined('INSTALL_PATH')) { + define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); + } + require_once INSTALL_PATH . 'program/include/iniset.php'; + + $this->rcubeVersionCheck($package); + $config_file = $this->rcubeConfigFile(); $package_name = $this->getPackageName($package); $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; @@ -118,27 +119,28 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { - // initialize Roundcube environment $this->setRoundcubemailInstallPath($repo); - if (!defined('INSTALL_PATH')) { - define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); - } - require_once INSTALL_PATH . 'program/include/iniset.php'; - $this->rcubeVersionCheck($target); + $postUpdate = function () use ($initial, $target) { + // initialize Roundcube environment + if (!defined('INSTALL_PATH')) { + define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); + } + require_once INSTALL_PATH . 'program/include/iniset.php'; - $extra = $target->getExtra(); - $fs = new Filesystem(); + $this->rcubeVersionCheck($target); - // backup persistent files e.g. config.inc.php - $package_name = $this->getPackageName($initial); - $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; - $temp_dir = $package_dir . '-' . sprintf('%010d%010d', mt_rand(), mt_rand()); + $extra = $target->getExtra(); + $fs = new Filesystem(); + + // backup persistent files e.g. config.inc.php + $package_name = $this->getPackageName($initial); + $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; + $temp_dir = $package_dir . '-' . sprintf('%010d%010d', mt_rand(), mt_rand()); - // make a backup of existing files (for restoring persistent files) - $fs->copy($package_dir, $temp_dir); + // make a backup of existing files (for restoring persistent files) + $fs->copy($package_dir, $temp_dir); - $postUpdate = function () use ($target, $extra, $fs, $temp_dir) { $package_name = $this->getPackageName($target); $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; @@ -192,16 +194,17 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { - // initialize Roundcube environment $this->setRoundcubemailInstallPath($repo); - if (!defined('INSTALL_PATH')) { - define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); - } - require_once INSTALL_PATH . 'program/include/iniset.php'; - $config = $this->composer->getConfig()->get('roundcube'); + $postUninstall = function () use ($package) { + // initialize Roundcube environment + if (!defined('INSTALL_PATH')) { + define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); + } + require_once INSTALL_PATH . 'program/include/iniset.php'; + + $config = $this->composer->getConfig()->get('roundcube'); - $postUninstall = function () use ($package, $config) { // post-uninstall: deactivate package $package_name = $this->getPackageName($package); $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name;