Turn $wgExtensionFunctions[] closure into a function

Toplevel closures can apparently cause random crashed on PHP 5.3 with
APC, which is the setup WMF uses. Better safe than sorry, right?

Also added some `global` declarations. I don't think this has ever worked…

https://bugs.php.net/bug.php?id=52144

Change-Id: I1b4487c2403e297921be56037672a3f1a0d8d57a