core icon indicating copy to clipboard operation
core copied to clipboard

ContentTool Query returning 0 results when passing live:true

Open erickgonzalez opened this issue 2 years ago • 1 comments

Describe the bug When calling the query method of the content tool and if the query contains live:true or the page is live mode no results are being pulled.

The issue here is that we are passing the sort as the tmDate https://github.com/dotCMS/core/blob/e5b03624a40d2ecd03739ef66f5c5f8478fc233f/dotCMS/src/main/java/com/dotcms/rendering/velocity/viewtools/content/ContentTool.java#L287 https://github.com/dotCMS/core/blob/e5b03624a40d2ecd03739ef66f5c5f8478fc233f/dotCMS/src/main/java/com/dotcms/rendering/velocity/viewtools/content/util/ContentUtils.java#L341 so it will treat the call as it comes from TimeMachine, but when it tries to parse the Date it blows https://github.com/dotCMS/core/blob/e5b03624a40d2ecd03739ef66f5c5f8478fc233f/dotCMS/src/main/java/com/dotcms/rendering/velocity/viewtools/content/util/ContentUtils.java#L187 and we get this on the log:

16:05:57.554  WARN  util.ContentUtils - For input string: "modDate desc" @ url:GET//default/api/v1/page/render/test | lang:1 | ip:127.0.0.1 | Admin:true | start:05-18-2022 03:37:18 CST  ref:http://localhost:8080/dotAdmin/  ?language_id=1&mode=ADMIN_MODE >/ADMIN_MODE/5a99315d-4846-45b0-8c58-e8539bc3fc48/694805c6-8f07-467f-a434-0da04a93e9e5.fields

To Reproduce Steps to reproduce the behavior:

  1. Create a widget with the following code:
#set( $content = $dotcontent.query("+contentType:webPageContent +deleted:false +live:true",10000,"modDate desc") )
$content.size()
  1. Add the widget to any page
  2. See it returns 0 results.

Expected behavior Should return results.

Reproducible in 5.1.6 and demo (22.05). Customer ticket: https://dotcms.zendesk.com/agent/tickets/107317

erickgonzalez avatar May 19 '22 15:05 erickgonzalez