Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-20107

Dashes in YAML semantic configuration hash keys are converted to underscores

    Details

      Description

      This configuration:

      ezpublish.yml

      match:
          Map\Host:
              vm.ezpublish5-releasetest.admin: ezdemo_site_admin
              vm.ezpublish5-releasetest: ezdemo_site_user
              eng.1: eng
              ger.1: ger
              fre.1: fre
      

      Is converted into this map array:

      debug.php

      Array
      (
          [eng.1] => eng
          [ger.1] => ger
          [fre.1] => fre
          [vm.ezpublish5_releasetest.admin] => ezdemo_site_admin
          [vm.ezpublish5_releasetest] => ezdemo_site_user
      )
      

      the dashes in the siteaccess names are converted to underscores, and match does not work.

        Issue Links

          Activity

          Hide
          André Rømcke added a comment - - edited

          This issue was fixed (for 5.0) in:
          https://github.com/ezsystems/ezp-next/commit/49a0422465bf51c3e9270b89f874b7ea41ffb72c

          Which is a merge of the following workaround (for the Symfony "issue" described above):
          https://github.com/ezsystems/ezp-next/pull/152

          Show
          André Rømcke added a comment - - edited This issue was fixed (for 5.0) in: https://github.com/ezsystems/ezp-next/commit/49a0422465bf51c3e9270b89f874b7ea41ffb72c Which is a merge of the following workaround (for the Symfony "issue" described above): https://github.com/ezsystems/ezp-next/pull/152
          Hide
          Jérôme Vieilledent (Inactive) added a comment -

          PR done on Symfony repository: https://github.com/symfony/symfony/pull/6086

          Show
          Jérôme Vieilledent (Inactive) added a comment - PR done on Symfony repository: https://github.com/symfony/symfony/pull/6086
          Hide
          Bertrand Dunogier added a comment - - edited

          However, this is a critical issue in the current situation. Several workarounds are possible.

          quick & dirty, but riskless, fix: prefix all affected strings (override rules / image variations / hostnames / ... ?) with an underscore, and remove this underscore when reading the setting. Since the normalization is only performed on strings that only contain hyphens, no conversion will happen.

          This will be done transparently:

          • when reading semantic settings, in a specific callback, IF one of the affected key contains dashes, we prefix it with an _
          • the method that causes the bug is executed, but doesn't convert dashes to underscores, since the string already contains underscore (documented behaviour)
          • before writing the settings in the application (in the container), we remove the underscores we have added

          This means the change is purely temporary, and the system is in the same state before & after this limited part.

          Show
          Bertrand Dunogier added a comment - - edited However, this is a critical issue in the current situation. Several workarounds are possible. quick & dirty, but riskless, fix: prefix all affected strings (override rules / image variations / hostnames / ... ?) with an underscore, and remove this underscore when reading the setting. Since the normalization is only performed on strings that only contain hyphens, no conversion will happen. This will be done transparently: when reading semantic settings, in a specific callback, IF one of the affected key contains dashes, we prefix it with an _ the method that causes the bug is executed, but doesn't convert dashes to underscores, since the string already contains underscore (documented behaviour) before writing the settings in the application (in the container), we remove the underscores we have added This means the change is purely temporary, and the system is in the same state before & after this limited part.
          Hide
          Bertrand Dunogier added a comment -

          Reason: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/Definition/Processor.php#L55.

          In semantic configuration, if a yaml key has only hyphens and no underscores, they are converted to underscores.

          Since hyphens are valid in yaml keys, this can be considered as a symfony bug, and should on the long term be fixed as such.

          Show
          Bertrand Dunogier added a comment - Reason: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/Definition/Processor.php#L55 . In semantic configuration, if a yaml key has only hyphens and no underscores, they are converted to underscores. Since hyphens are valid in yaml keys, this can be considered as a symfony bug, and should on the long term be fixed as such.

            People

            • Assignee:
              Unassigned
              Reporter:
              Bertrand Dunogier
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours
                5h