From aac125ab0759cfa875c3f000af47517fb788b9d6 Mon Sep 17 00:00:00 2001 From: Lincoln Russell Date: Thu, 26 Dec 2024 14:22:26 -0500 Subject: [PATCH 1/4] fix: Use the source's default database prefix --- src/Controller.php | 2 +- src/Functions/core.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controller.php b/src/Controller.php index beba519b..77d82e56 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -90,7 +90,7 @@ public static function run(Request $request) $exportSourceCM = new ConnectionManager($request->get('source')); $importSourceCM = new ConnectionManager($request->get('target') ?? ''); // @todo Pass options not Request - $exportModel = exportModelFactory($request, $exportSourceCM, $storage, $importSourceCM); + $exportModel = exportModelFactory($request, $source, $exportSourceCM, $storage, $importSourceCM); // No permissions warning. $exportModel->comment('[ Porter never migrates user permissions! Reset user permissions afterward. ]' . "\n"); diff --git a/src/Functions/core.php b/src/Functions/core.php index 4d5157fa..bca46f63 100644 --- a/src/Functions/core.php +++ b/src/Functions/core.php @@ -116,6 +116,7 @@ function postscriptFactory(string $target, Storage $storage, ConnectionManager $ /** * @param Request $request + * @param Source $source * @param ConnectionManager $exportSourceCM * @param Storage $storage * @param ConnectionManager $importSourceCM @@ -123,6 +124,7 @@ function postscriptFactory(string $target, Storage $storage, ConnectionManager $ */ function exportModelFactory( Request $request, + Source $source, ConnectionManager $exportSourceCM, Storage $storage, ConnectionManager $importSourceCM @@ -134,7 +136,7 @@ function exportModelFactory( $model = new ExportModel($db, $map, $storage, $importSourceCM); // Set model properties. - $model->srcPrefix = $request->get('src-prefix') ?? ''; + $model->srcPrefix = $request->get('src-prefix') ?? $source::SUPPORTED['prefix']; $model->testMode = $request->get('test') ?? false; $model->limitTables((string) $request->get('tables')); $model->captureOnly = $request->get('dumpsql') ?? false; From 6afe61b6331f33deb4eab0a216fb40af28a47e54 Mon Sep 17 00:00:00 2001 From: Lincoln Russell Date: Thu, 26 Dec 2024 14:23:08 -0500 Subject: [PATCH 2/4] fix: Rename Vanilla2 source to Vanilla --- data/sources.php | 2 +- src/Command/ShowCommand.php | 8 ++++---- src/Source/{Vanilla2.php => Vanilla.php} | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/Source/{Vanilla2.php => Vanilla.php} (99%) diff --git a/data/sources.php b/data/sources.php index 5ebfdfcc..36d15c32 100644 --- a/data/sources.php +++ b/data/sources.php @@ -32,8 +32,8 @@ 'Smf2', 'Toast', 'UserVoice', + 'Vanilla', 'Vanilla1', - 'Vanilla2', 'VBulletin', 'VBulletin5', 'WebWiz', diff --git a/src/Command/ShowCommand.php b/src/Command/ShowCommand.php index 1273446c..72b05ebd 100644 --- a/src/Command/ShowCommand.php +++ b/src/Command/ShowCommand.php @@ -17,9 +17,9 @@ public function __construct() ->argument('', 'Name of package.') ->usage( ' show [type] [name] ## Show features of a package.' . - ' show source vanilla2 ' . + ' show source Vanilla ' . '## Show what features can be migrated from Vanilla.' . - ' show target flarum ## Show what features can be migrated to Flarum.' + ' show target Flarum ## Show what features can be migrated to Flarum.' ); } @@ -56,9 +56,9 @@ public static function viewFeatureList(string $type, string $name) // Output. $writer = new Writer(); - if ($type === 'target' && strtolower($name) === 'vanilla2') { + if ($type === 'target' && strtolower($name) === 'vanilla') { // Vanilla is the intermediary format, so all features are supported by necessity. - $writer->bold->green->write("\n" . 'All features are supported for target Vanilla2.' . "\n"); + $writer->bold->green->write("\n" . 'All features are supported for target Vanilla.' . "\n"); } elseif (!array_key_exists($name, $supported)) { // Error message for invalid package names. $writer->bold->yellow->write("\n" . 'Unknown package "' . $name . '". Package is case-sensitive.' . "\n"); diff --git a/src/Source/Vanilla2.php b/src/Source/Vanilla.php similarity index 99% rename from src/Source/Vanilla2.php rename to src/Source/Vanilla.php index f6158bc8..2206f145 100644 --- a/src/Source/Vanilla2.php +++ b/src/Source/Vanilla.php @@ -12,7 +12,7 @@ use Porter\Source; use Porter\ExportModel; -class Vanilla2 extends Source +class Vanilla extends Source { public const SUPPORTED = [ 'name' => 'Vanilla 2+', From d2df798c74b4d7a1bf84eeb45cd453d9eb40b266 Mon Sep 17 00:00:00 2001 From: Lincoln Russell Date: Thu, 26 Dec 2024 14:26:06 -0500 Subject: [PATCH 3/4] fix: Rename dedault target connection to 'target' --- config-sample.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config-sample.php b/config-sample.php index ae7e81c0..3b41a337 100644 --- a/config-sample.php +++ b/config-sample.php @@ -19,7 +19,7 @@ ], ], [ - 'alias' => 'test', + 'alias' => 'target', 'type' => 'database', 'adapter' => 'mysql', 'host' => '127.0.0.1', From f2fdc7c9c48c5a5b4690ce1756ecda4514c336cb Mon Sep 17 00:00:00 2001 From: Lincoln Russell Date: Thu, 26 Dec 2024 14:38:38 -0500 Subject: [PATCH 4/4] fix: More prominently inform PORT_ tables may be deleted --- src/Controller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Controller.php b/src/Controller.php index 77d82e56..558edaf3 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -133,6 +133,9 @@ public static function run(Request $request) } else { $exportModel->comment("No Postscript found."); } + + // Doing this cleanup automatically is complex, so tell them to do it manually for now. + $exportModel->comment("After testing import, you may delete `PORT_` database tables."); } // End timer & report.