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

          Bertrand Dunogier created issue -
          Bertrand Dunogier made changes -
          Field Original Value New Value
          Description This configuration:

          {code:title=ezpublish.yml}
          match:
              Map\Host:
                  vm.ezpublish5-releasetest.admin: ezdemo_site_admin
                  screwit: screwit
                  vm.ezpublish5-releasetest: ezdemo_site_user
                  eng.1: eng
                  ger.1: ger
                  fre.1: fre
          {code}

          Is converted into this map array:

          {code:title=debug.php}
          Array
          (
              [screwit] => screwit
              [eng.1] => eng
              [ger.1] => ger
              [fre.1] => fre
              [vm.ezpublish5_releasetest.admin] => ezdemo_site_admin
              [vm.ezpublish5_releasetest] => ezdemo_site_user
          )
          {code}

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

          {code:title=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
          {code}

          Is converted into this map array:

          {code:title=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
          )
          {code}

          the dashes in the siteaccess names are converted to underscores, and match does not work.
          Bertrand Dunogier made changes -
          Status Open [ 1 ] Backlog [ 10000 ]
          André Rømcke made changes -
          Status Backlog [ 10000 ] InputQ [ 10001 ]
          André Rømcke made changes -
          Fix Version/s Engineering tracked issues [ 11179 ]
          André Rømcke made changes -
          Assignee Jerome Vieilledent [ jerome.vieilledent@ez.no ]
          André Rømcke made changes -
          Component/s HMVC stack [ 10303 ]
          Bertrand Dunogier made changes -
          Summary Dashes in Map\Host siteaccess matching are converted to underscores Dashes in YAML semantic configuration hash keys are converted to underscores
          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.
          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.
          André Rømcke made changes -
          Affects Version/s Known Issues [ 11285 ]
          Affects Version/s 5.0.0 [ 10300 ]
          Affects Version/s 5.0.0rc1 [ 11080 ]
          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
          Bertrand Dunogier made changes -
          Comment [ My vote would go to the quick & dirty one + fix in symfony. The moment this is fixed in Symfony, no change will be required, and the workaround can safely be removed. ]
          Bertrand Dunogier made changes -
          Status InputQ [ 10001 ] Development [ 3 ]
          Assignee Bertrand Dunogier [ bertrand.dunogier@ez.no ]
          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
          Bertrand Dunogier logged work - 23/Nov/12 9:37 AM
          • Time Spent:
            5 hours
             
            <No comment>
          Bertrand Dunogier made changes -
          Remaining Estimate 0 minutes [ 0 ]
          Time Spent 5 hours [ 18000 ]
          Worklog Id 24033 [ 24033 ]
          Bertrand Dunogier made changes -
          Status Development [ 3 ] Devlopment done [ 5 ]
          Bertrand Dunogier made changes -
          Status Devlopment done [ 5 ] Documentation done [ 10011 ]
          Bertrand Dunogier made changes -
          Original Estimate 0 minutes [ 0 ]
          Fix Version/s 5.0.0 [ 10300 ]
          Affects Version/s 5.0.0rc1 [ 11080 ]
          Affects Version/s 5.0.0 [ 10300 ]
          Vidar Langseid made changes -
          Fix Version/s QA tracked issues [ 11072 ]
          Fix Version/s 5.0 Certification [ 11013 ]
          Vidar Langseid made changes -
          Status Documentation done [ 10011 ] QA [ 10008 ]
          Assignee Bertrand Dunogier [ bertrand.dunogier@ez.no ] Vidar Langseid [ vidar.langseid@ez.no ]
          Vidar Langseid made changes -
          Status QA [ 10008 ] QA done [ 10007 ]
          André Rømcke made changes -
          Assignee Vidar Langseid [ vidar.langseid@ez.no ]
          Status QA done [ 10007 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Vidar Langseid made changes -
          Link This issue relates to EZP-20155 [ EZP-20155 ]
          André Rømcke made changes -
          Workflow eZ Community Workflow [ 34659 ] eZ Engineering Scrumban Workflow [ 48752 ]
          Joao Inacio (Inactive) made changes -
          Link This issue relates to EZP-20010 [ EZP-20010 ]
          André Rømcke made changes -
          Workflow eZ Engineering Scrumban Workflow [ 48752 ] EZ* Development Workflow [ 83312 ]
          Alex Schuster made changes -
          Workflow EZ* Development Workflow [ 83312 ] EZEE Development Workflow [ 121897 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Backlog Backlog
          3m 57s 1 Bertrand Dunogier 21/Nov/12 1:20 PM
          Backlog Backlog InputQ InputQ
          3m 56s 1 André Rømcke 21/Nov/12 1:24 PM
          InputQ InputQ Development Development
          22h 23m 1 Bertrand Dunogier 22/Nov/12 11:48 AM
          Development Development Development Done Development Done
          21h 48m 1 Bertrand Dunogier 23/Nov/12 9:37 AM
          Development Done Development Done Documentation Review done Documentation Review done
          45s 1 Bertrand Dunogier 23/Nov/12 9:38 AM
          Documentation Review done Documentation Review done QA QA
          5m 3s 1 Vidar Langseid 23/Nov/12 9:43 AM
          QA QA QA Done QA Done
          6s 1 Vidar Langseid 23/Nov/12 9:43 AM
          QA Done QA Done Closed Closed
          25m 32s 1 André Rømcke 23/Nov/12 10:08 AM

            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