Fixes NPE and duplicate data error when accessing or publishing a past revision.