Skip to content
Merged
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
54 changes: 54 additions & 0 deletions .github/workflows/test-various.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 14 additions & 0 deletions lib/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
40 changes: 40 additions & 0 deletions tests/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)/
*/
Expand Down
15 changes: 15 additions & 0 deletions tests/features/user.ini.feature
Original file line number Diff line number Diff line change
@@ -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"
Binary file modified updater.phar
Binary file not shown.
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '32b8a4525fb72023a82b5f99e69db0e7b0e87a60',
'reference' => 'b3abd9dd7a47e3d528896ef838a12193a08cd3db',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '32b8a4525fb72023a82b5f99e69db0e7b0e87a60',
'reference' => 'b3abd9dd7a47e3d528896ef838a12193a08cd3db',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down