Fix $wgSharedDB with sqlite
At the time of the constructor, tableAliases will always be an empty
array. As such, the ATTACH command is never run for shared dbs, and we
get query errors when later trying to reference them. This changes it so
that the shared db is attached whenever the table aliases are finally
set.
Since table aliases may be set multiple times, the list of already
attached dbs was moved into class scope so that subsequent calls to set
the aliases do not result in query errors.
Bug: T181962
Change-Id: Ia654e996f54077bc3749b884a528e121ab25a2d2