@adrian, it might be something that only happens with particularly complex modules, because I think I've added the namespace to a bunch of my earlier modules and never struck that problem. And if I test with a dummy module...
<?php
class TestModule extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'Test Module',
'summary' => 'Test applying namespace',
'version' => '0.1.0',
'autoload' => true,
);
}
public function ready() {
$this->addHookAfter('AdminTheme::getExtraMarkup', $this, 'doSomething');
}
protected function doSomething(HookEvent $event) {
$parts = $event->return;
$parts['masthead'] .= "hello";
$event->return = $parts;
}
}
...then I can add the namespace without issue. If I remove the namespace from a namespaced module then I get a server error, but that's not something anyone would need to do.
Just a guess, but you could try removing the previously compiled module files from /site/assets/cache/FileCompiler/site/ in the upgrade() method to see if that makes a difference.