Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.3"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/roundcube/roundcubemail.git"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
Expand Down
33 changes: 18 additions & 15 deletions src/ExtensionInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ private function initializeRoundcubemailEnvironment(): void
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$this->setRoundcubemailInstallPath($repo);
$this->initializeRoundcubemailEnvironment();
$this->rcubeVersionCheck($package);

$postInstall = function () use ($package) {
$this->initializeRoundcubemailEnvironment();
$this->rcubeVersionCheck($package);

$config_file = $this->rcubeConfigFile();
$package_name = $this->getPackageName($package);
$package_dir = $this->getInstallPath($package);
Expand Down Expand Up @@ -134,20 +135,21 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
$this->setRoundcubemailInstallPath($repo);
$this->initializeRoundcubemailEnvironment();
$this->rcubeVersionCheck($target);

$extra = $target->getExtra();
$fs = new Filesystem();
$postUpdate = function () use ($initial, $target) {
$this->initializeRoundcubemailEnvironment();
$this->rcubeVersionCheck($target);

$extra = $target->getExtra();
$fs = new Filesystem();

// backup persistent files e.g. config.inc.php
$package_dir = $this->getInstallPath($initial);
$temp_dir = $package_dir . '-' . sprintf('%010d%010d', mt_rand(), mt_rand());
// backup persistent files e.g. config.inc.php
$package_dir = $this->getInstallPath($initial);
$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->getInstallPath($target);

Expand Down Expand Up @@ -199,11 +201,12 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$this->setRoundcubemailInstallPath($repo);
$this->initializeRoundcubemailEnvironment();

$config = $this->composer->getConfig()->get('roundcube');
$postUninstall = function () use ($package) {
$this->initializeRoundcubemailEnvironment();

$config = $this->composer->getConfig()->get('roundcube');

$postUninstall = function () use ($package, $config) {
// post-uninstall: deactivate package
$package_name = $this->getPackageName($package);
$package_dir = $this->getInstallPath($package);
Expand Down
7 changes: 2 additions & 5 deletions test-composer/composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"name": "roundcube/plugin-installer-test",
"require": {
"roundcube/carddav": "^4 || ^5"
"roundcube/carddav": "^4 || ^5",
"roundcube/roundcubemail": "dev-master as 1.99"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/roundcube/roundcubemail.git"
},
{
"type": "path",
"url": ".."
Expand Down