Tweak for r50609: use $wgDatabase rather than wfGetDB( DB_MASTER )