From 003a69c8189cbae3b16ad575ce649ad1c8dfbeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 3 May 2024 10:50:59 +0200 Subject: [PATCH] Fix config preserve during composer update --- .github/workflows/ci.yml | 13 +++++++++++++ src/ExtensionInstaller.php | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b39dee6..3ccccbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,3 +116,16 @@ jobs: cd test-composer/vendor/roundcube/roundcubemail ls -lah plugins/acl/config.* if [ ! -f plugins/acl/config.inc.php ]; then echo 'Config file was not created' && exit 1; fi + + - name: Test update - install plugin + run: | + cd test-composer + echo '// xxx no config update xxx' >> vendor/roundcube/roundcubemail/plugins/carddav/config.inc.php + composer update -v --prefer-dist --no-interaction --no-progress roundcube/carddav --prefer-lowest + + - name: Test update - verify install + run: | + cd test-composer + ls -lah vendor/roundcube/roundcubemail/plugins/carddav/config.* + if [ ! -f vendor/roundcube/roundcubemail/plugins/carddav/config.inc.php ]; then echo 'Config file was deleted' && exit 1; fi + if ! grep -Fq 'xxx no config update xxx' vendor/roundcube/roundcubemail/plugins/carddav/config.inc.php; then echo 'Config file was replaced' && exit 1; fi diff --git a/src/ExtensionInstaller.php b/src/ExtensionInstaller.php index 8cfbd61..e24cd01 100644 --- a/src/ExtensionInstaller.php +++ b/src/ExtensionInstaller.php @@ -63,13 +63,19 @@ public function getInstallPath(PackageInterface $package) private function initializeRoundcubemailEnvironment(): void { - // initialize Roundcube environment if (!defined('INSTALL_PATH')) { define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); } require_once INSTALL_PATH . 'program/include/iniset.php'; } + public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) + { + $this->setRoundcubemailInstallPath($repo); + + return parent::isInstalled($repo, $package); + } + public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { $this->setRoundcubemailInstallPath($repo);