From 9fca0c029993a83290d40455ed6ae841d528a904 Mon Sep 17 00:00:00 2001 From: Michael Utz Date: Mon, 6 Jun 2022 18:26:02 +0300 Subject: [PATCH 1/4] Fix exception from autoloading when running `orbit:cache` --- src/Commands/CacheCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/CacheCommand.php b/src/Commands/CacheCommand.php index 7950863..e1b0eb9 100644 --- a/src/Commands/CacheCommand.php +++ b/src/Commands/CacheCommand.php @@ -53,7 +53,7 @@ protected function findOrbitModels(): Collection return $class; }) ->filter(function ($class) { - if (! class_exists($class)) { + if (! class_exists($class, false)) { return false; } From edbc4be80a1004d505405351b9cd4f0e649de454 Mon Sep 17 00:00:00 2001 From: Michael Utz Date: Mon, 6 Jun 2022 19:21:19 +0300 Subject: [PATCH 2/4] Revert autoloading change --- src/Commands/CacheCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/CacheCommand.php b/src/Commands/CacheCommand.php index e1b0eb9..7950863 100644 --- a/src/Commands/CacheCommand.php +++ b/src/Commands/CacheCommand.php @@ -53,7 +53,7 @@ protected function findOrbitModels(): Collection return $class; }) ->filter(function ($class) { - if (! class_exists($class, false)) { + if (! class_exists($class)) { return false; } From a34340c7798db02b8547c6d909b4cf1ffd0a1394 Mon Sep 17 00:00:00 2001 From: Michael Utz Date: Mon, 6 Jun 2022 19:21:42 +0300 Subject: [PATCH 3/4] Remove appended `\\` from namespace --- src/Commands/CacheCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/CacheCommand.php b/src/Commands/CacheCommand.php index 7950863..988d917 100644 --- a/src/Commands/CacheCommand.php +++ b/src/Commands/CacheCommand.php @@ -46,7 +46,7 @@ protected function findOrbitModels(): Collection $path = $item->getRelativePathName(); $class = sprintf( '\%s%s', - $laravel->getNamespace().'\\', + $laravel->getNamespace(), strtr(substr($path, 0, strrpos($path, '.')), '/', '\\') ); From 9cea7f89f66591b71d7ea18f96c69f0e9fde3562 Mon Sep 17 00:00:00 2001 From: Michael Utz Date: Tue, 7 Jun 2022 10:08:35 +0300 Subject: [PATCH 4/4] Attempt a more backwards-compatible fix --- src/Commands/CacheCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/CacheCommand.php b/src/Commands/CacheCommand.php index 988d917..1bb09d7 100644 --- a/src/Commands/CacheCommand.php +++ b/src/Commands/CacheCommand.php @@ -44,9 +44,10 @@ protected function findOrbitModels(): Collection ->map(function ($item) use ($laravel) { // Convert file path to namespace $path = $item->getRelativePathName(); + $ns = $laravel->getNamespace(); $class = sprintf( '\%s%s', - $laravel->getNamespace(), + str_ends_with($ns, "\\") ? $ns : $ns."\\", strtr(substr($path, 0, strrpos($path, '.')), '/', '\\') );