Skip to content

Commit

Permalink
XWIKI-9046: Renaming a document holding a lot of revisions can lead t…
Browse files Browse the repository at this point in the history
…o an OutOfMemory exception

* Only load last node when updating the document archive
  • Loading branch information
pjeanjean committed Mar 6, 2024
1 parent 0ad5064 commit 9360c8f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.xpn.xwiki.XWiki;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.criteria.impl.RangeFactory;
import com.xpn.xwiki.criteria.impl.RevisionCriteria;
import com.xpn.xwiki.criteria.impl.RevisionCriteriaFactory;
import com.xpn.xwiki.doc.XWikiAttachment;
Expand Down Expand Up @@ -284,7 +285,11 @@ public void updateXWikiDocArchive(XWikiDocument doc, boolean bTransaction, XWiki
XWikiContext context = getExecutionXContext(inputxcontext, true);

try {
XWikiDocumentArchive archiveDoc = getXWikiDocumentArchive(doc, context);
RevisionCriteria criteria = new RevisionCriteria();
criteria.setIncludeMinorVersions(true);
criteria.setRange(RangeFactory.getLAST());

XWikiDocumentArchive archiveDoc = getXWikiDocumentArchive(doc, criteria, context);
UserReferenceSerializer<String> userReferenceSerializer = Utils.getComponent(
new DefaultParameterizedType(null, UserReferenceSerializer.class, String.class));
String author = userReferenceSerializer.serialize(doc.getAuthors().getOriginalMetadataAuthor());
Expand Down

0 comments on commit 9360c8f

Please sign in to comment.