Skip to content

Commit

Permalink
Include RC iniset.php using async promise
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 20, 2024
1 parent 4d91081 commit b4b6e2b
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions src/ExtensionInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b4b6e2b

Please sign in to comment.