Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/1823 when combined with https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/858.