System settings php to yml conversion


I’m just performing an upgrade from Pimcore 5.8.9 to 6.6.2. Everything runs fines so far, however, I came across migration Version20190527121800 which deals with conversion from system.php configuration to system.yml to satisfy Symfony 4 demands.

This migration doesn’t seem to take environment dependent system configurations into account such as system_[environment].php. I try to visualize this in the code fragment below:

(42) $originalConfigFile = \Pimcore\Config::locateConfigFile('system.php'); // yields system_[environment].php
(43) $newConfigFile = str_replace('system.php', 'system.yml', $originalConfigFile); // yields system_[environment].php (and not system_[environment].yml)
(56) File::put($newConfigFile, $content); // writes the new yml configuration into system_[environment].php

In fact the migration yields the current used configuration and receives something like system_[environemnt].php as pathinformation to the configuration file. The subsequent call tries to replace system.php with system.yml which fails as system.php cannot be found and ($newConfigFile === $originalConfigFile) = true. In line 56 the yml style configuration is being written to the $newConfigFile which is still system_[environment].php.

I have elevated your code from migration Version20190527121800.php and wrote my own snippet to handle all configuration files system.php and system_[environment].php.

// Define folders to search for config files.
$configFolder = preg_filter('/$/', "/system*.{php}", [

// Find all files system_[environment].php and system.php.
$pattern = implode(",", $configFolder);
$configFiles = glob("{{$pattern}}", GLOB_BRACE);
$configFiles = array_filter($configFiles, function($v) {
    return preg_match('/system(.*?_(?:[[:alnum:]]+))?(.php)$/',$v);

foreach($configFiles as $configFile) {
    $newConfigFile = str_replace('.php', '.yml', $configFile);

    // Process only if the files doesn't exists yet.
    if(!file_exists($newConfigFile)) {
        $content = null;

... then your migration code applies too each of the configuration file in the loop


Hi Andreas, thanks for your findings. Can you please provide a PR for you changes?