Fix getDBName to read from $wgConf and cache if possible

Change-Id: Iafa2dde83ea3b1e19ad891b0a0e421836c2565e3