Hi everyone,
I broke the API backward compatibility in XWiki 15.5RC1 by adding a new method to the DocumentAccessBridge#getCurrentDocument()
without sending a vote for it. See https://www.xwiki.org/xwiki/bin/view/ReleaseNotes/Data/XWiki/15.5RC1/#HRealbreakages . The question is now how to handle this:
- Leave it like this (accept the API breakage because having this new method there makes sense and because chances that someone implemented the
DocumentAccessBridge
interface without extending our default implementation are low) - Add a default implementation that return
null
@Unstable default DocumentModelBridge getCurrentDocument() { return null; }
- Add a default implementation that uses
getTranslatedDocumentInstance
:@Unstable default DocumentModelBridge getCurrentDocument() { DocumentModelBridge result; try { result = getTranslatedDocumentInstance(getCurrentDocumentReference()); } catch (Exception e) { result = null; } return result; }
- Remove the new method and use the
ExecutionContext
instead:@Inject private Execution execution; execution.getContext().getProperty("xwikicontext").get("doc");
- Remove the new method and refactor the code to use oldcore directly (
XWikiContext
)
On my side:
- I find it acceptable and I vote for it.
- I don’t like that it creates an inconsistency between
getCurrentDocumentReference
andgetCurrentDocument
(normally if one is not null then both should be not null, and if one is null then both should be null) - I don’t like that it gives the false impression that you don’t need to implement this method (it’s optional), but I guess this could be mitigated with a comment explaining the limitations of the default implementation.
- I find this too fragile
- I don’t like it either because I think it’s better / cleaner to avoid depending on oldcore if possible
So I’m +1 for option 1 but I’ll accept option 3 if others vote for it.
Thanks,
Marius