Revert "Issue #2176621 by sun, alexpott: Remove global $databases." Broke testbots

This reverts commit 06e6e9238fda103eeeae28098deaef1c9734a667.