Repair broken parent link in the scanner - stable6

backport of #8968 

cc @PVince81 @ser72 @karlitschek @craigpg
The change isn't master due to the deletion of the permissions table