Skip to content

Commit 3f539d7

Browse files
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 <es-github@rosenberg.org.il>
1 parent 52d092d commit 3f539d7

2 files changed

Lines changed: 30 additions & 114 deletions

File tree

lib/private/Config.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@
1616
*/
1717
class Config {
1818
public const ENV_PREFIX = 'NC_';
19+
public const CONF_WARNING = "
20+
/*
21+
* WARNING
22+
*
23+
* This file gets modified by automatic processes and all lines that are not
24+
* active code (ie. comments) are lost during that process.
25+
*
26+
* If you want to document things with comments or use constants add your settings
27+
* in a '<NAME>.config.php' file which will be included and rendered into this file.
28+
*
29+
* Example:
30+
* <?php
31+
* \$CONFIG = [];
32+
*
33+
* See also: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-merged-configuration-files
34+
*/
35+
";
1936

2037
protected array $cache = [];
2138
protected array $envCache = [];
@@ -268,25 +285,9 @@ private function writeData(): void {
268285
}
269286

270287
// Create a php file ...
271-
$content = "<?php
272-
273-
/*
274-
* WARNING
275-
*
276-
* This file gets modified by automatic processes and all lines that are not
277-
* active code (ie. comments) are lost during that process.
278-
*
279-
* If you want to document things with comments or use constants add your settings
280-
* in a '<NAME>.config.php' file which will be included and rendered into this file.
281-
*
282-
* Example:
283-
* <?php
284-
* \$CONFIG = [];
285-
*
286-
* See also: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-merged-configuration-files
287-
*/
288-
289-
\$CONFIG = ";
288+
$content = "<?php\n";
289+
$content .= self::CONF_WARNING;
290+
$content .= '$CONFIG = ';
290291
$content .= var_export(self::trustSystemConfig($this->cache), true);
291292
$content .= ";\n";
292293

tests/lib/ConfigTest.php

Lines changed: 10 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,8 @@ public function testSetValue(): void {
9797
$this->assertSame('moo', $config->getValue('foo'));
9898

9999
$content = file_get_contents($this->configFile);
100-
$expected = "<?php
101-
102-
/*
103-
* WARNING
104-
*
105-
* This file gets modified by automatic processes and all lines that are not
106-
* active code (ie. comments) are lost during that process.
107-
*
108-
* If you want to document things with comments or use constants add your settings
109-
* in a '<NAME>.config.php' file which will be included and rendered into this file.
110-
*
111-
* Example:
112-
* <?php
113-
* \$CONFIG = [];
114-
*
115-
* See also: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-merged-configuration-files
116-
*/
117-
118-
";
100+
$expected = "<?php\n";
101+
$expected .= \OC\Config::CONF_WARNING;
119102
$expected .= "\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n "
120103
. " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n);\n";
121104
$this->assertEquals($expected, $content);
@@ -127,25 +110,8 @@ public function testSetValue(): void {
127110

128111
$content = file_get_contents($this->configFile);
129112

130-
$expected = "<?php
131-
132-
/*
133-
* WARNING
134-
*
135-
* This file gets modified by automatic processes and all lines that are not
136-
* active code (ie. comments) are lost during that process.
137-
*
138-
* If you want to document things with comments or use constants add your settings
139-
* in a '<NAME>.config.php' file which will be included and rendered into this file.
140-
*
141-
* Example:
142-
* <?php
143-
* \$CONFIG = [];
144-
*
145-
* See also: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-merged-configuration-files
146-
*/
147-
148-
";
113+
$expected = "<?php\n";
114+
$expected .= \OC\Config::CONF_WARNING;
149115
$expected .= "\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n "
150116
. " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n 'bar' => 'red',\n 'apps' => \n "
151117
. " array (\n 0 => 'files',\n 1 => 'gallery',\n ),\n);\n";
@@ -177,25 +143,8 @@ public function testSetValues(): void {
177143
$this->assertSame(null, $config->getValue('not_exists'));
178144

179145
$content = file_get_contents($this->configFile);
180-
$expected = "<?php
181-
182-
/*
183-
* WARNING
184-
*
185-
* This file gets modified by automatic processes and all lines that are not
186-
* active code (ie. comments) are lost during that process.
187-
*
188-
* If you want to document things with comments or use constants add your settings
189-
* in a '<NAME>.config.php' file which will be included and rendered into this file.
190-
*
191-
* Example:
192-
* <?php
193-
* \$CONFIG = [];
194-
*
195-
* See also: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-merged-configuration-files
196-
*/
197-
198-
";
146+
$expected = "<?php\n";
147+
$expected .= \OC\Config::CONF_WARNING;
199148
$expected .= "\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n "
200149
. " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n);\n";
201150
$this->assertEquals($expected, $content);
@@ -207,25 +156,8 @@ public function testDeleteKey(): void {
207156
$this->assertSame('this_was_clearly_not_set_before', $config->getValue('foo', 'this_was_clearly_not_set_before'));
208157
$content = file_get_contents($this->configFile);
209158

210-
$expected = "<?php
211-
212-
/*
213-
* WARNING
214-
*
215-
* This file gets modified by automatic processes and all lines that are not
216-
* active code (ie. comments) are lost during that process.
217-
*
218-
* If you want to document things with comments or use constants add your settings
219-
* in a '<NAME>.config.php' file which will be included and rendered into this file.
220-
*
221-
* Example:
222-
* <?php
223-
* \$CONFIG = [];
224-
*
225-
* See also: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-merged-configuration-files
226-
*/
227-
228-
";
159+
$expected = "<?php\n";
160+
$expected .= \OC\Config::CONF_WARNING;
229161
$expected .= "\$CONFIG = array (\n 'beers' => \n array (\n 0 => 'Appenzeller',\n "
230162
. " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n);\n";
231163
$this->assertEquals($expected, $content);
@@ -246,25 +178,8 @@ public function testConfigMerge(): void {
246178

247179
// Write a new value to the config
248180
$config->setValue('CoolWebsites', ['demo.owncloud.org', 'owncloud.org', 'owncloud.com']);
249-
$expected = "<?php
250-
251-
/*
252-
* WARNING
253-
*
254-
* This file gets modified by automatic processes and all lines that are not
255-
* active code (ie. comments) are lost during that process.
256-
*
257-
* If you want to document things with comments or use constants add your settings
258-
* in a '<NAME>.config.php' file which will be included and rendered into this file.
259-
*
260-
* Example:
261-
* <?php
262-
* \$CONFIG = [];
263-
*
264-
* See also: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-merged-configuration-files
265-
*/
266-
267-
";
181+
$expected = "<?php\n";
182+
$expected .= \OC\Config::CONF_WARNING;
268183
$expected .= "\$CONFIG = array (\n 'foo' => 'bar',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n "
269184
. " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n 'php53' => 'totallyOutdated',\n 'CoolWebsites' => \n array (\n "
270185
. " 0 => 'demo.owncloud.org',\n 1 => 'owncloud.org',\n 2 => 'owncloud.com',\n ),\n);\n";

0 commit comments

Comments
 (0)