From 02e5470163c1f795b5ec2fdab4651a0a0526fe8e Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 21 Oct 2025 11:12:18 +0300 Subject: [PATCH] Put warn counting in cache.Load the plugin in the Application.php. --- .../src/Command/TransmogrifyCommand.php | 14 +++++++------- .../src/Lib/Traits/ManageDefaultsTrait.php | 1 + .../src/Lib/Traits/RowTransformationTrait.php | 1 + app/src/Application.php | 6 ++++++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/plugins/Transmogrify/src/Command/TransmogrifyCommand.php b/app/plugins/Transmogrify/src/Command/TransmogrifyCommand.php index 17377e906..73a325a1e 100644 --- a/app/plugins/Transmogrify/src/Command/TransmogrifyCommand.php +++ b/app/plugins/Transmogrify/src/Command/TransmogrifyCommand.php @@ -356,8 +356,8 @@ public function execute(Arguments $args, ConsoleIo $io): int } $this->cmdPrinter->start($count); $tally = 0; - $warns = 0; - $err = 0; + $this->cache['error'] = 0; + $this->cache['warns'] = 0; while ($row = $stmt->fetchAssociative()) { if(!empty($row[ $this->tables[$t]['displayField'] ])) { @@ -404,7 +404,7 @@ public function execute(Arguments $args, ConsoleIo $io): int // load this record. This can happen, eg, because the source_field_id // did not load, perhaps because it was associated with an Org Identity // not linked to a CO Person that was not migrated. - $warns++; + $this->cache['warns'] += 1; $this->cache['rejected'][$outboundQualifiedTableName][$row['id']] = $row; $this->cmdPrinter->warning("Skipping $t record " . $row['id'] . " due to invalid foreign key: " . $e->getMessage()); $this->cmdPrinter->pause(); @@ -412,13 +412,13 @@ public function execute(Arguments $args, ConsoleIo $io): int catch(\InvalidArgumentException $e) { // If we can't find a value for mapping we skip the record // (ie: mapLegacyFieldNames basically requires a successful mapping) - $warns++; + $this->cache['warns'] += 1; $this->cache['rejected'][$outboundQualifiedTableName][$row['id']] = $row; $this->cmdPrinter->warning("Skipping $t record " . $row['id'] . ": " . $e->getMessage()); $this->cmdPrinter->pause(); } catch(\Exception $e) { - $err++; + $this->cache['error'] += 1; $this->cmdPrinter->error("$t record " . $row['id'] . ": " . $e->getMessage()); $this->cmdPrinter->pause(); } @@ -434,8 +434,8 @@ public function execute(Arguments $args, ConsoleIo $io): int */ // Output final warning and error counts for the table - $this->cmdPrinter->warning(sprintf('Warnings: %d', $warns)); - $this->cmdPrinter->error(sprintf('Errors: %d', $err)); + $this->cmdPrinter->warning(sprintf('Warnings: %d', $this->cache['warns'])); + $this->cmdPrinter->error(sprintf('Errors: %d', $this->cache['error'])); // Execute any post-processing hooks for the table if($this->cache['skipInsert'][$outboundQualifiedTableName] === false) { diff --git a/app/plugins/Transmogrify/src/Lib/Traits/ManageDefaultsTrait.php b/app/plugins/Transmogrify/src/Lib/Traits/ManageDefaultsTrait.php index 8fcc56395..d1f4a8ec9 100644 --- a/app/plugins/Transmogrify/src/Lib/Traits/ManageDefaultsTrait.php +++ b/app/plugins/Transmogrify/src/Lib/Traits/ManageDefaultsTrait.php @@ -67,6 +67,7 @@ protected function createOwnersGroups(): void } } catch(\Exception $e) { + $this->cache['error'] += 1; $this->cmdPrinter->error("Failed to create owners group for " . $group->name . " (" . $group->id . "): " . $e->getMessage()); diff --git a/app/plugins/Transmogrify/src/Lib/Traits/RowTransformationTrait.php b/app/plugins/Transmogrify/src/Lib/Traits/RowTransformationTrait.php index 6d5b0943a..dd7d1194c 100644 --- a/app/plugins/Transmogrify/src/Lib/Traits/RowTransformationTrait.php +++ b/app/plugins/Transmogrify/src/Lib/Traits/RowTransformationTrait.php @@ -124,6 +124,7 @@ protected function reconcileGroupMembershipOwnership(array $origRow, array &$row $this->outconn->insert($qualifiedTableName, $ownerRow); } else { $this->cmdPrinter->error("Could not find owners group for CoGroupMember " . $origRow['id']); + $this->cache['error'] += 1; } } diff --git a/app/src/Application.php b/app/src/Application.php index 1e57c5454..ae0b8a6dd 100644 --- a/app/src/Application.php +++ b/app/src/Application.php @@ -69,6 +69,12 @@ public function bootstrap(): void foreach($activePlugins as $p) { $this->addPlugin($p->plugin); } + + // The Transmogrify plugin is required for all applications + // It is a special use case. + if (!\Cake\Core\Plugin::isLoaded('Transmogrify')) { + $this->addPlugin('Transmogrify'); + } } catch(\Cake\Database\Exception\DatabaseException $e) { // Most likely we are performing the initial database setup and