Fix documentation of HistoryPager::lastLink() and make code more readable

- Describe the possible types of $next parameter in the documentation
  rather than inline along with the possible values
- Split the big if ... elseif block into separate blocks. The elseif
  are not needed since each path returns
- Only create the revision object when really necessary

Change-Id: Ic92a6f6bd405d3f820d562a7322d34e3d9d33d17
Merge "Fix documentation of HistoryPager::lastLink() and make code more readable"