Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-5775

URL construction problem after using several times page Copy/Paste

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 4.8.0
    • None
    • None
    • None
    • 4.8.0 M11
    • 1 - Middle term
    • 2 - Normal

      If a same page with contents is used as a model to create new pages not really a problem.
      But in the following case:
      Model page -> Page1 pasted from Model page copy -> Page2 pasted from Page1 copy ... -> Pagen pasted from Page n-1 copy
      In this case the URL of the contents which are in Page n can be very long

      Example on customer website:
      (http-8080-44;/generate/XXXXX/_contents-images/ametys-internal%253Asites/XXXXX/ametys-internal%253Acontents/midem-entete-de-page-2-2-2-2-2-2-2-4-3-2-5-8-2-2-2-2-2-2-2-3-2-2-2/_metadata/header/1/header-illustration/image_287x1072/bandeau_liberation.jpg

      So as to avoid potential problem, it would be better to change naming content naming rules after Copy/Paste action

          [CMS-5775] URL construction problem after using several times page Copy/Paste

          or to add "-copy-1" and increment this
          or to add a forbiddent scheme such as "-2" as "-" cannot be created by the user, you will sure that incrementation is fine.

          Raphaël Franchet added a comment - or to add "-copy-1" and increment this or to add a forbiddent scheme such as "- 2" as " -" cannot be created by the user, you will sure that incrementation is fine.

          After each copy of content, the content is prefix by -2 as content name already exist.
          So, when the copy is done from the last copied page recursively, we have : content-name -> content-name-2 -> content-name-2-2 -> content-name-2-2-2 -> etc ...

          This is due to the following piece of code in copy function of CopiableContentComponent:

          String originalName = name == null ? originalContent.getName() : name;
          String contentName = originalName;
          int index = 2;
          while (parent.hasChild(contentName))
          {
                contentName = originalName + "-" + (index++);
          }
          

          Maybe we can test if original name ends with "-X" where X is a number and increase X ... But if X comes from original content's title (ex: "Les chiffres de 2015" -> les-chiffres-de-2015") we can not do the difference.

          Anywhere, I am not sure the current naming rule is a problem and the described use case seems not a real use case, but seems to be use case for test ?

          Laurence Aumeunier added a comment - After each copy of content, the content is prefix by -2 as content name already exist. So, when the copy is done from the last copied page recursively, we have : content-name -> content-name-2 -> content-name-2-2 -> content-name-2-2-2 -> etc ... This is due to the following piece of code in copy function of CopiableContentComponent : String originalName = name == null ? originalContent.getName() : name; String contentName = originalName; int index = 2; while (parent.hasChild(contentName)) { contentName = originalName + "-" + (index++); } Maybe we can test if original name ends with "-X" where X is a number and increase X ... But if X comes from original content's title (ex: "Les chiffres de 2015" -> les-chiffres-de-2015") we can not do the difference. Anywhere, I am not sure the current naming rule is a problem and the described use case seems not a real use case, but seems to be use case for test ?

            raphael Raphaël Franchet
            dcartier David Cartier-Michaud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: