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 Feb 23, 2024
1 parent eaddc5e commit 2aa8775
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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.doc.XWikiAttachment;
import com.xpn.xwiki.doc.XWikiDocument;
Expand Down Expand Up @@ -283,7 +284,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 2aa8775

Please sign in to comment.