pageid parser function is expensive, make it so
The pageid parser function (not to be confused with the pageid magic
word) hits the database for every title passed, which meets the criteria
for being considered an expensive parser function.
To mitigate this new expensiveness, check for special namespaces,
interwiki titles, and titles in LinkCache before hitting the DB.
Also, record potentially-valid titles in pagelinks so that the page can
be properly purged if the target is created/deleted.
Change-Id: I4fbfc265543f0a64c14dc8a44e1c89cd928a1adb