Problem statement
There are various use cases in core and extensions not directly related to URL-shortening. Cases where one want to show urls to users that should take advantage of URL shortening. There should be a core service to support this transformation, where you can pass in an URL (or maybe a Title object and an array of query parameters) and get back another URL which resolves to the same address but if possible is shorter.
Proposal
The default behavior in MediaWiki core could be to just return the URL unchanged, or maybe to use curid instead of title page name (that changes the semantics though as page name and page id are not inseparably linked together).
The non-default behavior could be implemented by an extension like UrlShortener.
One complication is that shortening a URL that wasn't shortened before requires a DB write, which should be avoided on GET requests.
Another is that it should work with cross-DB titles (as the main use case is Commons file description pages).
See also:
- File::getDescriptionShortUrl()