From 217058b47561f2b7457a695ca61fc5c419383e46 Mon Sep 17 00:00:00 2001 From: Gerhard Seidel Date: Fri, 18 Oct 2019 13:11:49 +0200 Subject: [PATCH] [Routing] fix route loading with wildcard, but dir or file is empty --- .../Routing/Loader/Configurator/RoutingConfigurator.php | 3 ++- src/Symfony/Component/Routing/Loader/XmlFileLoader.php | 2 +- src/Symfony/Component/Routing/Loader/YamlFileLoader.php | 2 +- .../Tests/Fixtures/controller/empty_wildcard/.gitignore | 0 .../Tests/Fixtures/import_with_name_prefix/routing.yml | 4 ++++ 5 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/controller/empty_wildcard/.gitignore diff --git a/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php index a315cfb4ad..849db56759 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php @@ -39,7 +39,8 @@ class RoutingConfigurator final public function import($resource, $type = null, $ignoreErrors = false) { $this->loader->setCurrentDir(\dirname($this->path)); - $imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file); + $imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file) ?? []; + if (!\is_array($imported)) { return new ImportConfigurator($this->collection, $imported); } diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index ed4faf3915..7b5998bd20 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -169,7 +169,7 @@ class XmlFileLoader extends FileLoader $this->setCurrentDir(\dirname($path)); /** @var RouteCollection[] $imported */ - $imported = $this->import($resource, ('' !== $type ? $type : null), false, $file); + $imported = $this->import($resource, ('' !== $type ? $type : null), false, $file) ?? []; if (!\is_array($imported)) { $imported = [$imported]; diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 15c223ecad..339776c13f 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -187,7 +187,7 @@ class YamlFileLoader extends FileLoader $this->setCurrentDir(\dirname($path)); - $imported = $this->import($config['resource'], $type, false, $file); + $imported = $this->import($config['resource'], $type, false, $file) ?? []; if (!\is_array($imported)) { $imported = [$imported]; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/controller/empty_wildcard/.gitignore b/src/Symfony/Component/Routing/Tests/Fixtures/controller/empty_wildcard/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/import_with_name_prefix/routing.yml b/src/Symfony/Component/Routing/Tests/Fixtures/import_with_name_prefix/routing.yml index 90dce0ea1b..057b7b2d6b 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/import_with_name_prefix/routing.yml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/import_with_name_prefix/routing.yml @@ -5,3 +5,7 @@ api: resource: ../controller/routing.yml name_prefix: api_ prefix: /api + +empty_wildcard: + resource: ../controller/empty_wildcard/* + prefix: /empty_wildcard