Uploaded image for project: 'Magnolia Categorization Module'
  1. Magnolia Categorization Module
  2. MGNLCAT-197

getContentByCategoryIdentifier templating function returns invalid results

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Neutral
    • 2.9.1
    • 2.7.1
    • None

    Description

      Steps to reproduce

      1.  Create a page that contains a link to another page
      2.  Call getContentByCategoryIdentifier(String, String) in CategorizationTemplatingFunctions to get all the content that is related to category whose uuid is the uuid of the page linked in previous step, i.e. what is passed as parameter is not the UUID of a category but another UUID (of a page). You can make use of the following script:
        catfn = info.magnolia.objectfactory.Components.getComponent(info.magnolia.module.categorization.functions.CategorizationTemplatingFunctions.class)
        println(catfn.getContentByCategoryIdentifier("PATH", "UUID"))
        

      Expected results

      Since passed UUID is not a category, no results are returned

      Actual results

      Page with link is returned

      Workaround

      Create an alternative function just like the existing one but using JCR-SQL2 instead of the deprecated XPATH expression

      Development notes

      According to the query that is generated, it should look for UUIDs within categories property:

      ...[jcr:contains(.categories, ''{1}'')]"

      This is the only function making use of XPATH query, which is deprecated. Translating the existing query to the following would work as expected:

      select * from [mgnl:content] as t WHERE CONTAINS(t.categories,'UUID') AND ISDESCENDANTNODE('PATH')
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              lam.nguyen Lam Nguyen Bao
              jayala Jonathan Ayala
              AuthorX
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD

                  Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - Not Specified
                    Not Specified
                    Logged:
                    Time Spent - 1d 1h 10m
                    1d 1h 10m