Details
-
Bug
-
Resolution: Fixed
-
Neutral
-
6.2.8
-
None
-
Empty show more show less
-
Yes
-
Maintenance 61
-
2
Description
Steps to reproduce
In order to quickly reproduce the issue we are going to force assets to have subnodes
- Go to JCR app and navigate to /tours/shark_brian_warrick_0824.JPG and import the attached XML dam.tours.shark_brian_warrick_0824..JPG.test.xml
- Add restorePreviousVersion to the action bar in dam assets app: edit /dam-app-jcr/decorations/dam-assets-app/apps/dam.subApps.yaml to add it as follows:
versions: items: - name: showVersions - name: restoreVersion - name: restorePreviousVersion
- Open assets app and go to /tours/shark_brian_warrick_0824.JPG. Publish it to make sure there are versions available
- Click on restore previous action in the action bar
Expected results
Previous version is restored ok
Actual results
An error is thrown with no detailed information of the cause
Workaround
Using restore version action
Development notes
This error happens only when there are subnodes in the item. When debugging RestorePreviousVersionCommand you can see that the cause is a nullPointerException which is thrown in info.magnolia.commands.impl.RestorePreviousVersionCommand.getPreviousVersion(Node) method, specifically here:
VersionIterator versionIterator = versionManager.getAllVersions(node);
while (versionIterator.hasNext()) {
previousVersion = versionIterator.nextVersion();
}
versionManager.getAllVersions can return null in two scenarios, if versionedNode is null and if versionHistory is null. Therefore, if one of these situations occurs, the next instruction, versionIterator.hasNext(), will throw a null pointer exception.
SOLUTION: add a null control before the while loop:
VersionIterator versionIterator = versionManager.getAllVersions(node); if(versionIterator!=null){ while (versionIterator.hasNext()) { previousVersion = versionIterator.nextVersion(); } }
Checklists
Attachments
Issue Links
- is cloned by
-
MGNLUI-6734 Can't send notification to view "ui-admincentral:longRunning"
-
- Closed
-
- relates to
-
MAGNOLIA-8048 Remove hasVersion mixin when there is no version
-
- Closed
-