diff --git a/src/Core/DB/SchemaDefDriver.php b/src/Core/DB/SchemaDefDriver.php index 8af09be152..186d18261c 100644 --- a/src/Core/DB/SchemaDefDriver.php +++ b/src/Core/DB/SchemaDefDriver.php @@ -75,10 +75,11 @@ class SchemaDefDriver extends StaticPHPDriver { $schema = $class_name::schemaDef(); - $metadata->setPrimaryTable(['name' => $schema['name'], - 'indexes' => self::kv_to_name_col($schema['indexes'] ?? []), - 'uniqueConstraints' => self::kv_to_name_col($schema['unique keys'] ?? []), - 'options' => ['comment' => $schema['description'] ?? ''], + $metadata->setPrimaryTable([ + 'name' => $schema['name'], + 'indexes' => self::kv_to_name_col($schema['indexes'] ?? []), + 'uniqueConstraints' => self::kv_to_name_col($schema['unique keys'] ?? []), + 'options' => ['comment' => $schema['description'] ?? ''], ]); foreach ($schema['fields'] as $name => $opts) { diff --git a/src/Core/GNUsocial.php b/src/Core/GNUsocial.php index 8bf33d2f4a..57c48853a6 100644 --- a/src/Core/GNUsocial.php +++ b/src/Core/GNUsocial.php @@ -137,6 +137,8 @@ class GNUsocial implements EventSubscriberInterface HTTPClient::setClient($this->client); if (isset($_ENV['HTTPS']) || isset($_ENV['HTTP_HOST'])) { + // TODO move to container definition, after removing + // this way of doing configuration DefaultSettings::setDefaults(); } diff --git a/src/Core/ModuleManager.php b/src/Core/ModuleManager.php index 239c1e087b..c3af8af47c 100644 --- a/src/Core/ModuleManager.php +++ b/src/Core/ModuleManager.php @@ -83,12 +83,11 @@ class ModuleManager } } - public static function process(ContainerBuilder $container) + public static function process(?ContainerBuilder $container = null) { $module_paths = array_merge(glob(INSTALLDIR . '/components/*/*.php'), glob(INSTALLDIR . '/plugins/*/*.php')); $module_manager = new self(); $entity_paths = []; - $default_driver = $container->findDefinition('doctrine.orm.default_metadata_driver'); foreach ($module_paths as $path) { // 'modules' and 'plugins' have the same length $type = ucfirst(preg_replace('%' . INSTALLDIR . '/(component|plugin)s/.*%', '\1', $path)); @@ -96,17 +95,19 @@ class ModuleManager $module = basename($dir); $fqcn = "\\{$type}\\{$module}\\{$module}"; $module_manager->add($fqcn, $path); - if (file_exists($dir = $dir . '/Entity') && is_dir($dir)) { + if (!is_null($container) && file_exists($dir = $dir . '/Entity') && is_dir($dir)) { $entity_paths[] = $dir; - $default_driver->addMethodCall( + $container->findDefinition('doctrine.orm.default_metadata_driver')->addMethodCall( 'addDriver', [new Reference('app.core.schemadef_driver'), "{$type}\\{$module}\\Entity"] ); } } - $container->findDefinition('app.core.schemadef_driver') - ->addMethodCall('addPaths', ['$paths' => $entity_paths]); + if (!is_null($container)) { + $container->findDefinition('app.core.schemadef_driver') + ->addMethodCall('addPaths', ['$paths' => $entity_paths]); + } $module_manager->preRegisterEvents(); @@ -132,6 +133,7 @@ class ModuleManager $time = file_exists(CACHE_FILE) ? filemtime(CACHE_FILE) : 0; if (F\some($rdi, function ($e) use ($time) { return $e->getMTime() > $time; })) { + Log::info('Rebuilding plugin cache at runtime. This means we can\'t update DB definitions'); self::process(); } }