Improve implementation to check read access to forks and add pagination.
Fixes#13648
The following optimizations where made:
- Pagination was added.
- Code to check for read permissions to forks was optimized, in the past we were doing too many queries for each project.
See merge request !2991