From 52d092da64c0a7fdd49ddcbd0aa536d5cb17172c Mon Sep 17 00:00:00 2001 From: "E.S. Rosenberg a.k.a. Keeper of the Keys" Date: Mon, 6 Apr 2026 00:46:26 +0300 Subject: [PATCH 1/2] feat: add config header and tests. Signed-off-by: E.S. Rosenberg a.k.a. Keeper of the Keys --- lib/private/Config.php | 21 +++++++- tests/lib/ConfigTest.php | 105 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 119 insertions(+), 7 deletions(-) diff --git a/lib/private/Config.php b/lib/private/Config.php index ec380aedc5d0b..44a26a1677757 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -268,8 +268,25 @@ private function writeData(): void { } // Create a php file ... - $content = ".config.php' file which will be included and rendered into this file. + * + * Example: + * cache), true); $content .= ";\n"; diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php index b2a52dbd6a449..3ef54f7644fc0 100644 --- a/tests/lib/ConfigTest.php +++ b/tests/lib/ConfigTest.php @@ -97,7 +97,26 @@ public function testSetValue(): void { $this->assertSame('moo', $config->getValue('foo')); $content = file_get_contents($this->configFile); - $expected = " 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " + $expected = ".config.php' file which will be included and rendered into this file. + * + * Example: + * 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n);\n"; $this->assertEquals($expected, $content); @@ -108,7 +127,26 @@ public function testSetValue(): void { $content = file_get_contents($this->configFile); - $expected = " 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " + $expected = ".config.php' file which will be included and rendered into this file. + * + * Example: + * 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n 'bar' => 'red',\n 'apps' => \n " . " array (\n 0 => 'files',\n 1 => 'gallery',\n ),\n);\n"; $this->assertEquals($expected, $content); @@ -139,7 +177,26 @@ public function testSetValues(): void { $this->assertSame(null, $config->getValue('not_exists')); $content = file_get_contents($this->configFile); - $expected = " 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " + $expected = ".config.php' file which will be included and rendered into this file. + * + * Example: + * 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n);\n"; $this->assertEquals($expected, $content); } @@ -150,7 +207,26 @@ public function testDeleteKey(): void { $this->assertSame('this_was_clearly_not_set_before', $config->getValue('foo', 'this_was_clearly_not_set_before')); $content = file_get_contents($this->configFile); - $expected = " \n array (\n 0 => 'Appenzeller',\n " + $expected = ".config.php' file which will be included and rendered into this file. + * + * Example: + * \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n);\n"; $this->assertEquals($expected, $content); } @@ -170,7 +246,26 @@ public function testConfigMerge(): void { // Write a new value to the config $config->setValue('CoolWebsites', ['demo.owncloud.org', 'owncloud.org', 'owncloud.com']); - $expected = " 'bar',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " + $expected = ".config.php' file which will be included and rendered into this file. + * + * Example: + * 'bar',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n 'php53' => 'totallyOutdated',\n 'CoolWebsites' => \n array (\n " . " 0 => 'demo.owncloud.org',\n 1 => 'owncloud.org',\n 2 => 'owncloud.com',\n ),\n);\n"; $this->assertEquals($expected, file_get_contents($this->configFile)); From 3f539d78e3cbcdf773e80924ef3e5eef928d6dc9 Mon Sep 17 00:00:00 2001 From: "E.S. Rosenberg a.k.a. Keeper of the Keys" Date: Tue, 7 Apr 2026 11:47:14 +0300 Subject: [PATCH 2/2] fix: change config-warning to const per @come-nc request in the PR. Signed-off-by: E.S. Rosenberg a.k.a. Keeper of the Keys --- lib/private/Config.php | 39 ++++++++------- tests/lib/ConfigTest.php | 105 ++++----------------------------------- 2 files changed, 30 insertions(+), 114 deletions(-) diff --git a/lib/private/Config.php b/lib/private/Config.php index 44a26a1677757..1a8337907f125 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -16,6 +16,23 @@ */ class Config { public const ENV_PREFIX = 'NC_'; + public const CONF_WARNING = " +/* + * WARNING + * + * This file gets modified by automatic processes and all lines that are not + * active code (ie. comments) are lost during that process. + * + * If you want to document things with comments or use constants add your settings + * in a '.config.php' file which will be included and rendered into this file. + * + * Example: + * .config.php' file which will be included and rendered into this file. - * - * Example: - * cache), true); $content .= ";\n"; diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php index 3ef54f7644fc0..f4177fb19129c 100644 --- a/tests/lib/ConfigTest.php +++ b/tests/lib/ConfigTest.php @@ -97,25 +97,8 @@ public function testSetValue(): void { $this->assertSame('moo', $config->getValue('foo')); $content = file_get_contents($this->configFile); - $expected = ".config.php' file which will be included and rendered into this file. - * - * Example: - * 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n);\n"; $this->assertEquals($expected, $content); @@ -127,25 +110,8 @@ public function testSetValue(): void { $content = file_get_contents($this->configFile); - $expected = ".config.php' file which will be included and rendered into this file. - * - * Example: - * 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n 'bar' => 'red',\n 'apps' => \n " . " array (\n 0 => 'files',\n 1 => 'gallery',\n ),\n);\n"; @@ -177,25 +143,8 @@ public function testSetValues(): void { $this->assertSame(null, $config->getValue('not_exists')); $content = file_get_contents($this->configFile); - $expected = ".config.php' file which will be included and rendered into this file. - * - * Example: - * 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n);\n"; $this->assertEquals($expected, $content); @@ -207,25 +156,8 @@ public function testDeleteKey(): void { $this->assertSame('this_was_clearly_not_set_before', $config->getValue('foo', 'this_was_clearly_not_set_before')); $content = file_get_contents($this->configFile); - $expected = ".config.php' file which will be included and rendered into this file. - * - * Example: - * \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n);\n"; $this->assertEquals($expected, $content); @@ -246,25 +178,8 @@ public function testConfigMerge(): void { // Write a new value to the config $config->setValue('CoolWebsites', ['demo.owncloud.org', 'owncloud.org', 'owncloud.com']); - $expected = ".config.php' file which will be included and rendered into this file. - * - * Example: - * 'bar',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n 'php53' => 'totallyOutdated',\n 'CoolWebsites' => \n array (\n " . " 0 => 'demo.owncloud.org',\n 1 => 'owncloud.org',\n 2 => 'owncloud.com',\n ),\n);\n";