From 61755e0a66d18f42feaa8dfea5078e2f72a862db Mon Sep 17 00:00:00 2001 From: Rob Thomas Date: Mon, 10 Jun 2019 08:39:11 +1000 Subject: [PATCH 1/2] Fixes UserFrosting#965 - Ignore files that don't end in .php This ignores any files in Migrations that do not end in .php. It causes problems when scripts, or data, or documentation is left in the Migrations directory, and the migration task assumes that they are PHP Classes and crashes. Signed-Off-By: Rob Thomas --- .../core/src/Database/Migrator/MigrationLocator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php b/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php index 58f4ce6bb..3ee918af1 100644 --- a/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php +++ b/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php @@ -54,7 +54,11 @@ public function getMigrations() $migrations = []; foreach ($migrationFiles as $migrationFile) { - $migrations[] = $this->getMigrationDetails($migrationFile); + // Note that PSR4 insists that all php files must end in PHP, so ignore all + // files that don't end in PHP. + if (preg_match('/php$/', $migrationFile)) { + $migrations[] = $this->getMigrationDetails($migrationFile); + } } return $migrations; From e32313e640c8563f53d7aefe8182e7644e6457a2 Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Wed, 12 Jun 2019 21:11:11 -0400 Subject: [PATCH 2/2] Added test for PR #998 --- .../Integration/Database/Migrator/MigrationLocatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php b/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php index 44c842263..a5c0fbdcb 100644 --- a/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php +++ b/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php @@ -90,6 +90,7 @@ public function testGetMigrations() new Resource($resourceStream, $resourceAccountLocation, 'one/CreatePasswordResetsTable.php'), new Resource($resourceStream, $resourceAccountLocation, 'two/CreateFlightsTable.php'), new Resource($resourceStream, $resourceAccountLocation, 'CreateMainTable.php'), + new Resource($resourceStream, $resourceAccountLocation, 'README.md'), // This shoudn't be returned by the migrator ]); // Create a new MigrationLocator instance with our simulated ResourceLocation @@ -109,7 +110,6 @@ public function testGetMigrations() ]; // Test results match expectations - $this->assertCount(8, $results); $this->assertEquals($expected, $results); return $locator;