Currently, api.Document.getPreviousVersion() calls doc.XWikiDocument.getPreviousVersion()
which
calls doc.XWikiDocument.getDocumentArchive() which will return null if the document
archive is not
currently loaded.
doc.XWikiDocument.getPreviousVersion() is inherently dangerous and should be deprecated
then removed.
doc.XWikiDocument.getDocumentArchive() sometimes returns null and should be deprecated
then made private.
everywhere doc.XWikiDocument.getDocumentArchive() is used it should be replaced with
doc.XWikiDocument.getDocumentArchive(XWikiContext) which calls loadDocumentArchive first.
What I propose we do now (for 2.3)
#1
Change api.Document.getPreviousVersion() to call getDocumentArchive(getXWikiContext()) and
move the logic
from doc.XWikiDocument.getPreviousVersion() into api.Document.getPreviousVersion()
#2
change doc.XWikiDocument.copyDocument(DocumentReference newDocumentReference, XWikiContext
context) to call
getDocumentArchive(XWikiContext) instead of getDocumentArchive()
#3
Add warnings in javadoc for:
clone(XWikiDocument document)
cloneInternal(DocumentReference newDocumentReference, boolean keepsIdentity)
to say that they may not copy the archive since they use getDocumentArchive()
#4
mark doc.XWikiDocument.getPreviousVersion() and doc.XWikiDocument.getDocumentArchive() as
depricated and
explain why in a comment.
WDYT?
Caleb