Skip to content

Commit

Permalink
Put warn counting in cache.Load the plugin in the Application.php.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Oct 29, 2025
1 parent 93d5dc6 commit 5b32685
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/plugins/Transmogrify/src/Command/TransmogrifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ])) {
Expand Down Expand Up @@ -404,21 +404,21 @@ 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();
}
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();
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
6 changes: 6 additions & 0 deletions app/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b32685

Please sign in to comment.