This issue has been created
There are 3 updates, 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-9adc5733-889b-410c-99bc-795bee6db467 XWIKI-22187 Open

Cannot get revisions with a criteria on a document not stored in DB

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-8543acbc-39dd-41b7-bd11-5375c62ab460 Simon Urli created this issue on 24/May/24 12:19
 
Summary: Cannot get revisions with a criteria on a document not stored in DB
Issue Type: cid:jira-generated-image-avatar-9adc5733-889b-410c-99bc-795bee6db467 Bug
Affects Versions: 15.10.8, 16.2.0
Assignee: Unassigned
Components: Old Core
Created: 24/May/24 12:19
Labels: regression
Priority: cid:jira-generated-image-static-blocker-05b7dbf7-ef1d-48ca-aec5-b67b4902bbeb Blocker
Reporter: Simon Urli
Description:

Reproduction steps:

  • Create a page "Test" containing multiple revisions (I created 5 in my case)
  • Create a page "Script" containing the following snippet (ensure that the page created at step 1 has a reference "xwiki:Test.WebHome" or edit the script)
    {{velocity}}
    #set ($myTest = "xwiki:Test.WebHome")
    #set ($startAt = 0)
    #set ($endAt = -1)
    #set ($criteria = $xwiki.criteriaService.revisionCriteriaFactory.createRevisionCriteria('', $minorVersions))
    #set ($range = $xwiki.criteriaService.rangeFactory.createRange($startAt, $endAt))
    #set ($discard = $criteria.setRange($range))
    #set ($myDoc = $xwiki.getDocument($myTest))
    #set ($xwikiDoc = $myDoc.document)
    XWiki Doc: $xwikiDoc
    #set ($revisions = $xwikiDoc.getRevisions($criteria, $xcontext.context))
    Revision: $revisions
    #set ($discard = $xwikiDoc.setDocumentReference("xwiki:Foo.WebHome"))
    XWiki Doc: $xwikiDoc
    #set ($revisions = $xwikiDoc.getRevisions($criteria, $xcontext.context))
    Revision: $revisions
    {{/velocity}}
    
  • Save and view the page with the snippet

Expected result:

  • The page should display:
    XWiki Doc: Test.WebHome
    Revision: [5.1]
    XWiki Doc: Foo.WebHome
    Revision: [5.1]
    

Obtained result:

  • The page display:
    XWiki Doc: Test.WebHome
    Revision: [5.1]
    XWiki Doc: Foo.WebHome
    Revision: []
    
 
 

3 updates

 
cid:jira-generated-image-avatar-8543acbc-39dd-41b7-bd11-5375c62ab460 Changes by Simon Urli on 24/May/24 12:20
 
Fix Version: 16.4.0
Assignee: Simon Urli
 
cid:jira-generated-image-avatar-d3afbc2b-310b-4040-bb9b-7c010b45150c Changes by Thomas Mortagne on 24/May/24 12:21
 
Fix Version: 15.10.10
 
 

1 comment

 
cid:jira-generated-image-avatar-8543acbc-39dd-41b7-bd11-5375c62ab460 Simon Urli on 24/May/24 12:20
 

The problem is that now when a criteria is given to get revisions, the returned result systematically comes from a DB query, which will always return no result if the page is not saved in DB. We should instead always try to get results from the loaded archive when it's available.