소스 검색

removed automatic .ini configuration file migration, closes #808

El RIDO 5 년 전
부모
커밋
c758eca0a4
4개의 변경된 파일3개의 추가작업 그리고 78개의 파일을 삭제
  1. 1 0
      CHANGELOG.md
  2. 0 12
      lib/Configuration.php
  3. 2 3
      lib/Persistence/DataStore.php
  4. 0 63
      tst/ConfigurationTest.php

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@
     * ADDED: Google Cloud Storage backend support (#795)
     * CHANGED: Language selection cookie only transmitted over HTTPS (#472)
     * CHANGED: Upgrading libraries to: random_compat 2.0.20
+    * CHANGED: Removed automatic `.ini` configuration file migration (#808)
   * **1.3.5 (2021-04-05)**
     * ADDED: Translation for Hebrew, Lithuanian, Indonesian and Catalan
     * ADDED: Make the project info configurable (#681)

+ 0 - 12
lib/Configuration.php

@@ -106,20 +106,8 @@ class Configuration
     {
         $config     = array();
         $basePath   = (getenv('CONFIG_PATH') !== false ? getenv('CONFIG_PATH') : PATH . 'cfg') . DIRECTORY_SEPARATOR;
-        $configIni  = $basePath . 'conf.ini';
         $configFile = $basePath . 'conf.php';
 
-        // rename INI files to avoid configuration leakage
-        if (is_readable($configIni)) {
-            DataStore::prependRename($configIni, $configFile, ';');
-
-            // cleanup sample, too
-            $configIniSample = $configIni . '.sample';
-            if (is_readable($configIniSample)) {
-                DataStore::prependRename($configIniSample, $basePath . 'conf.sample.php', ';');
-            }
-        }
-
         if (is_readable($configFile)) {
             $config = parse_ini_file($configFile, true);
             foreach (array('main', 'model', 'model_options') as $section) {

+ 2 - 3
lib/Persistence/DataStore.php

@@ -80,15 +80,14 @@ class DataStore extends AbstractPersistence
      * @static
      * @param  string $srcFile
      * @param  string $destFile
-     * @param  string $prefix (optional)
      * @return void
      */
-    public static function prependRename($srcFile, $destFile, $prefix = '')
+    public static function prependRename($srcFile, $destFile)
     {
         // don't overwrite already converted file
         if (!is_readable($destFile)) {
             $handle = fopen($srcFile, 'r', false, stream_context_create());
-            file_put_contents($destFile, $prefix . self::PROTECTION_LINE . PHP_EOL);
+            file_put_contents($destFile, self::PROTECTION_LINE . PHP_EOL);
             file_put_contents($destFile, $handle, FILE_APPEND);
             fclose($handle);
         }

+ 0 - 63
tst/ConfigurationTest.php

@@ -147,44 +147,6 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('Database', $conf->getKey('class', 'model'), 'old db class gets renamed');
     }
 
-    public function testHandleConfigFileRename()
-    {
-        $options  = $this->_options;
-        Helper::createIniFile(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample', $options);
-
-        $options['main']['opendiscussion'] = true;
-        $options['main']['fileupload']     = true;
-        $options['main']['template']       = 'darkstrap';
-        Helper::createIniFile(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', $options);
-
-        $conf = new Configuration;
-        $this->assertFileExists(CONF, 'old configuration file gets converted');
-        $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed');
-        $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample', 'old configuration sample file gets removed');
-        $this->assertTrue(
-            $conf->getKey('opendiscussion') &&
-            $conf->getKey('fileupload') &&
-            $conf->getKey('template') === 'darkstrap',
-            'configuration values get converted'
-        );
-    }
-
-    public function testRenameIniSample()
-    {
-        $iniSample = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample';
-
-        Helper::createIniFile(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', $this->_options);
-        if (is_file(CONF)) {
-            unlink(CONF);
-        }
-        rename(CONF_SAMPLE, $iniSample);
-        new Configuration;
-        $this->assertFileNotExists($iniSample, 'old sample file gets removed');
-        $this->assertFileExists(CONF_SAMPLE, 'new sample file gets created');
-        $this->assertFileExists(CONF, 'old configuration file gets converted');
-        $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed');
-    }
-
     public function testConfigPath()
     {
         // setup
@@ -204,29 +166,4 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
         }
         putenv('CONFIG_PATH');
     }
-
-    public function testConfigPathIni()
-    {
-        // setup
-        $configFile              = $this->_path . DIRECTORY_SEPARATOR . 'conf.ini';
-        $configMigrated          = $this->_path . DIRECTORY_SEPARATOR . 'conf.php';
-        $options                 = $this->_options;
-        $options['main']['name'] = 'OtherBin';
-        Helper::createIniFile($configFile, $options);
-        $this->assertFileNotExists(CONF, 'configuration in the default location is non existing');
-
-        // test
-        putenv('CONFIG_PATH=' . $this->_path);
-        $conf = new Configuration;
-        $this->assertEquals('OtherBin', $conf->getKey('name'), 'changing config path is supported for ini files as well');
-        $this->assertFileExists($configMigrated, 'old configuration file gets converted');
-        $this->assertFileNotExists($configFile, 'old configuration file gets removed');
-        $this->assertFileNotExists(CONF, 'configuration is not created in the default location');
-
-        // cleanup environment
-        if (is_file($configFile)) {
-            unlink($configFile);
-        }
-        putenv('CONFIG_PATH');
-    }
 }