From e9676545cea79ee53f2185e1bd51ecba2e52361f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 20 Feb 2024 14:57:47 +0000 Subject: [PATCH 1/5] Allows to not update the migrations date on publish --- .../Console/VendorPublishCommand.php | 31 +++++++++++++++++++ .../InteractsWithTestCaseLifecycle.php | 2 ++ 2 files changed, 33 insertions(+) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 037567f53445..40699d380a34 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -68,6 +68,13 @@ class VendorPublishCommand extends Command */ protected $description = 'Publish any publishable assets from vendor packages'; + /** + * Indicates if the migrations date should be updated. + * + * @var bool + */ + protected static $updateMigrationsDate = true; + /** * Create a new command instance. * @@ -341,6 +348,10 @@ protected function createParentDirectory($directory) */ protected function ensureMigrationNameIsUpToDate($from, $to) { + if (static::$updateMigrationsDate === false) { + return $to; + } + $from = realpath($from); foreach (ServiceProvider::publishableMigrationPaths() as $path) { @@ -381,4 +392,24 @@ protected function status($from, $to, $type) $to, )); } + + /** + * Intructs the command to not update the migrations date on publish. + * + * @return void + */ + public static function dontUpdateMigrationsDate() + { + static::$updateMigrationsDate = false; + } + + /** + * Flush the global state of the command. + * + * @return void + */ + public static function flushState() + { + static::$updateMigrationDate = true; + } } diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php index b3c5fd69562f..480ba7f32646 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php @@ -9,6 +9,7 @@ use Illuminate\Foundation\Bootstrap\HandleExceptions; use Illuminate\Foundation\Bootstrap\RegisterProviders; use Illuminate\Foundation\Console\AboutCommand; +use Illuminate\Foundation\Console\VendorPublishCommand; use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; use Illuminate\Foundation\Http\Middleware\TrimStrings; use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken; @@ -176,6 +177,7 @@ protected function tearDownTheTestEnvironment(): void TrustProxies::flushState(); TrustHosts::flushState(); ValidateCsrfToken::flushState(); + VendorPublishCommand::flushState(); if ($this->callbackException) { throw $this->callbackException; From efde57e1455adcc0ea33a2952e01eea93adac930 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 20 Feb 2024 15:04:38 +0000 Subject: [PATCH 2/5] fix --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 40699d380a34..a75b21ddeae8 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -410,6 +410,6 @@ public static function dontUpdateMigrationsDate() */ public static function flushState() { - static::$updateMigrationDate = true; + static::$updateMigrationsDate = true; } } From 0bbb45920eefdc54867c10c6a6ec7a7ec168aebd Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Feb 2024 11:19:33 -0600 Subject: [PATCH 3/5] formatting --- .../Console/VendorPublishCommand.php | 20 +++++-------------- .../InteractsWithTestCaseLifecycle.php | 2 -- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index a75b21ddeae8..a3d835617a80 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -73,7 +73,7 @@ class VendorPublishCommand extends Command * * @var bool */ - protected static $updateMigrationsDate = true; + protected static $updateMigrationDates = true; /** * Create a new command instance. @@ -348,7 +348,7 @@ protected function createParentDirectory($directory) */ protected function ensureMigrationNameIsUpToDate($from, $to) { - if (static::$updateMigrationsDate === false) { + if (static::$updateMigrationDates === false) { return $to; } @@ -394,22 +394,12 @@ protected function status($from, $to, $type) } /** - * Intructs the command to not update the migrations date on publish. + * Intructs the command to not update the dates on migrations when publishing. * * @return void */ - public static function dontUpdateMigrationsDate() + public static function dontUpdateMigrationDates() { - static::$updateMigrationsDate = false; - } - - /** - * Flush the global state of the command. - * - * @return void - */ - public static function flushState() - { - static::$updateMigrationsDate = true; + static::$updateMigrationDates = false; } } diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php index 480ba7f32646..b3c5fd69562f 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php @@ -9,7 +9,6 @@ use Illuminate\Foundation\Bootstrap\HandleExceptions; use Illuminate\Foundation\Bootstrap\RegisterProviders; use Illuminate\Foundation\Console\AboutCommand; -use Illuminate\Foundation\Console\VendorPublishCommand; use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; use Illuminate\Foundation\Http\Middleware\TrimStrings; use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken; @@ -177,7 +176,6 @@ protected function tearDownTheTestEnvironment(): void TrustProxies::flushState(); TrustHosts::flushState(); ValidateCsrfToken::flushState(); - VendorPublishCommand::flushState(); if ($this->callbackException) { throw $this->callbackException; From ac3be63cb0320d9a33e363712c00bddcfdd18f81 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Feb 2024 11:19:58 -0600 Subject: [PATCH 4/5] formatting --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index a3d835617a80..447faf2d8ead 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -394,7 +394,7 @@ protected function status($from, $to, $type) } /** - * Intructs the command to not update the dates on migrations when publishing. + * Intruct the command to not update the dates on migrations when publishing. * * @return void */ From 21204e8d9521babb79206b60aef3ea39b54c6298 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Feb 2024 11:20:19 -0600 Subject: [PATCH 5/5] formatting --- src/Illuminate/Foundation/Console/VendorPublishCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 447faf2d8ead..78dd9b68a940 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -69,7 +69,7 @@ class VendorPublishCommand extends Command protected $description = 'Publish any publishable assets from vendor packages'; /** - * Indicates if the migrations date should be updated. + * Indicates if migration dates should be updated while publishing. * * @var bool */