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

getContentByCategoryIdentifier templating function returns invalid results

XMLWordPrintable

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

      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')
      

        Acceptance criteria

          There are no Sub-Tasks for this issue.

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

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

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