diff --git a/.github/workflows/test-various.yml b/.github/workflows/test-various.yml new file mode 100644 index 00000000..1806f676 --- /dev/null +++ b/.github/workflows/test-various.yml @@ -0,0 +1,54 @@ +# SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT +name: Test various integration tests + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +jobs: + test-various: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ["8.2"] + + + name: test-various + + steps: + - name: Checkout + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: apcu,ctype,curl,dom,fileinfo,ftp,gd,intl,json,ldap,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip + coverage: none + ini-file: development + + - name: Install dependencies + run: composer i + + - name: test-user.ini + run: make test-user.ini + + summary: + runs-on: ubuntu-latest + needs: test-various + + if: always() + + name: test-various-summary + + steps: + - name: Summary status + run: if ${{ needs.test-various.result != 'success' }}; then exit 1; fi diff --git a/Makefile b/Makefile index 670752e3..e427aa6c 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,9 @@ test-stable26: updater.phar test/vendor test-master: updater.phar test/vendor cd tests && ../vendor/bin/behat features/master.feature +test-user.ini: updater.phar test/vendor + cd tests && ../vendor/bin/behat features/user.ini.feature + check-same-code-base: cd tests && php checkSameCodeBase.php diff --git a/index.php b/index.php index 2cded369..23e10fc4 100644 --- a/index.php +++ b/index.php @@ -1129,6 +1129,20 @@ public function finalize(): void { throw new \Exception('Could not rmdir .step'); } + /* Check if there is the need to extend .user.ini */ + $user_ini_additional_lines = $this->getConfigOption('user_ini_additional_lines'); + if ($user_ini_additional_lines) { + $this->silentLog('[info] Extend .user.ini'); + if (is_array($user_ini_additional_lines)) { + $user_ini_additional_lines = implode(PHP_EOL, $user_ini_additional_lines); + } + + $result = file_put_contents($this->nextcloudDir . '/.user.ini', PHP_EOL . '; Additional settings from config.php:' . PHP_EOL . $user_ini_additional_lines . PHP_EOL, FILE_APPEND); + if ($result === false) { + throw new \Exception('Could not append to .user.ini'); + } + } + if (function_exists('opcache_reset')) { $this->silentLog('[info] call opcache_reset()'); opcache_reset(); diff --git a/lib/Updater.php b/lib/Updater.php index b106ab97..6fd99fdc 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -1111,6 +1111,20 @@ public function finalize(): void { throw new \Exception('Could not rmdir .step'); } + /* Check if there is the need to extend .user.ini */ + $user_ini_additional_lines = $this->getConfigOption('user_ini_additional_lines'); + if ($user_ini_additional_lines) { + $this->silentLog('[info] Extend .user.ini'); + if (is_array($user_ini_additional_lines)) { + $user_ini_additional_lines = implode(PHP_EOL, $user_ini_additional_lines); + } + + $result = file_put_contents($this->nextcloudDir . '/.user.ini', PHP_EOL . '; Additional settings from config.php:' . PHP_EOL . $user_ini_additional_lines . PHP_EOL, FILE_APPEND); + if ($result === false) { + throw new \Exception('Could not append to .user.ini'); + } + } + if (function_exists('opcache_reset')) { $this->silentLog('[info] call opcache_reset()'); opcache_reset(); diff --git a/tests/features/bootstrap/FeatureContext.php b/tests/features/bootstrap/FeatureContext.php index 090f637f..af199ce6 100644 --- a/tests/features/bootstrap/FeatureContext.php +++ b/tests/features/bootstrap/FeatureContext.php @@ -402,6 +402,46 @@ public function theCurrentChannelIs($channel) { exec('./occ config:system:set --value ' . $channel . ' updater.release.channel'); } + /** + * @Given the config key :key is set to :value of type :type + * @param string $key + * @param mixed $value + * @param string $type ('string', 'boolean', 'integer', 'double') + */ + public function theConfigKeyIsSetTo(string $key, $value, string $type = 'string') { + if ($this->skipIt) { + return; + } + + if (!in_array($type, ['string', 'boolean', 'integer', 'double'])) { + throw new Exception('Invalid type given: ' . $type); + } + + chdir($this->serverDir . 'nextcloud'); + shell_exec('chmod +x occ'); + exec("./occ config:system:set $key --value '$value' --type '$type'"); + } + + /** + * @Then the user ini file contains :content + * @param string $content + */ + public function theUserIniFileContains(string $content) { + if ($this->skipIt) { + return; + } + + $userIniFile = $this->serverDir . 'nextcloud/.user.ini'; + if (!file_exists($userIniFile)) { + throw new Exception('User ini file does not exist: ' . $userIniFile); + } + + $contents = file_get_contents($userIniFile); + if (!str_contains($contents, $content)) { + throw new Exception('Content not found in user ini file: ' . $content); + } + } + /** * @Then /upgrade is (not required|required)/ */ diff --git a/tests/features/user.ini.feature b/tests/features/user.ini.feature new file mode 100644 index 00000000..064690ef --- /dev/null +++ b/tests/features/user.ini.feature @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +Feature: CLI updater - user.ini retention test + + Scenario: User.ini retention after update + Given the current installed version is 26.0.0rc1 + Given the config key "user_ini_additional_lines" is set to "upload_max_filesize = 10G\npost_max_size = 10G" of type "string" + And there is an update to version 26.0.0 available + When the CLI updater is run successfully + And the output should contain "Update successful" + Then the installed version should be 26.0 + And maintenance mode should be off + And upgrade is not required + And the user ini file contains "upload_max_filesize = 10G" + And the user ini file contains "post_max_size = 10G" diff --git a/updater.phar b/updater.phar index e011065a..7ac8073d 100755 Binary files a/updater.phar and b/updater.phar differ diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 2c8b8c64..906777e8 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '32b8a4525fb72023a82b5f99e69db0e7b0e87a60', + 'reference' => 'b3abd9dd7a47e3d528896ef838a12193a08cd3db', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '32b8a4525fb72023a82b5f99e69db0e7b0e87a60', + 'reference' => 'b3abd9dd7a47e3d528896ef838a12193a08cd3db', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),