Fix issues importing forked projects
Fixes 500 errors on forked projects.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/26184.
Also, more importantly, fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/29380
As all merge request diffs stopped working and no diff/commits were shown.
Does this MR meet the acceptance criteria?
- 
Changelog entry added 
- Tests
- 
Added for this feature/bug 
- 
All builds are passing 
 
- 
- 
Conform by the merge request performance guides 
- 
Conform by the style guides 
- 
Branch has no merge conflicts with master(if it does - rebase it please)
- 
Squashed related commits together