Followup I90849cd3: small logic fixes and improvements

Specifically, fix invocation of $dbr->select, avoid use of
$wgTitle, fix permissions checking and the language default
for the language selector.

Change-Id: I6c54e12c8ec163b4ebf2ba321c39ff3ed7234d61