From 0c17ffc944a156937732238c9d8b6f1e0049e5ea Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 30 Nov 2018 13:51:04 +1300 Subject: [PATCH] FIX: Manifest should ignore vendor folders within packages contained in vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change vendor/silverstripe/framework/vendor/silverstripe/config will be pick up by the manifest, which is inappropriate. Although this doesn’t happen often, it can occur if you have run “composer install” within vendor/silverstripe/framework, which can be done either accidentally or (in my case) as part of running the framework tests isolated from the rest of your project (which is closer to the execution model on Travis) Note that the presence of the ‘nestedvendor.txt’ file tests that this works without any explicit changes to the PHP of the tests, since it’s merely confirming that such a file is *not* picked up. --- src/Core/Manifest/ManifestFileFinder.php | 5 +++++ .../vendor/myvendor/thismodule/vendor/nestedvendor.txt | 1 + 2 files changed, 6 insertions(+) create mode 100644 tests/php/Core/Manifest/fixtures/manifestfilefinder/vendor/myvendor/thismodule/vendor/nestedvendor.txt diff --git a/src/Core/Manifest/ManifestFileFinder.php b/src/Core/Manifest/ManifestFileFinder.php index 995f944aa..697f9fd51 100644 --- a/src/Core/Manifest/ManifestFileFinder.php +++ b/src/Core/Manifest/ManifestFileFinder.php @@ -41,6 +41,11 @@ class ManifestFileFinder extends FileFinder // Keep searching inside vendor $inVendor = $this->isInsideVendor($basename, $pathname, $depth); if ($inVendor) { + // Skip nested vendor folders (e.g. vendor/silverstripe/framework/vendor) + if ($depth == 4 && basename($pathname) === self::VENDOR_DIR) { + return false; + } + // Keep searching if we could have a subdir module if ($depth < 3) { return true; diff --git a/tests/php/Core/Manifest/fixtures/manifestfilefinder/vendor/myvendor/thismodule/vendor/nestedvendor.txt b/tests/php/Core/Manifest/fixtures/manifestfilefinder/vendor/myvendor/thismodule/vendor/nestedvendor.txt new file mode 100644 index 000000000..e4fa5b54b --- /dev/null +++ b/tests/php/Core/Manifest/fixtures/manifestfilefinder/vendor/myvendor/thismodule/vendor/nestedvendor.txt @@ -0,0 +1 @@ +nestedvendor.txt