WIP
This commit is contained in:
@@ -59,10 +59,10 @@ final class CheckMissingCustomFieldValuesCommand extends Command
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$entityScope = (string) $input->getOption('entity');
|
||||
$limit = max(1, (int) $input->getOption('limit'));
|
||||
$maxRows = max(1, (int) $input->getOption('max-rows'));
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$entityScope = (string) $input->getOption('entity');
|
||||
$limit = max(1, (int) $input->getOption('limit'));
|
||||
$maxRows = max(1, (int) $input->getOption('max-rows'));
|
||||
$recoverableOnly = (bool) $input->getOption('recoverable-only');
|
||||
|
||||
if (!in_array($entityScope, ['all', 'piece', 'composant'], true)) {
|
||||
@@ -71,7 +71,7 @@ final class CheckMissingCustomFieldValuesCommand extends Command
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$rows = [];
|
||||
$counts = [
|
||||
'piece' => 0,
|
||||
'composant' => 0,
|
||||
@@ -202,7 +202,7 @@ final class CheckMissingCustomFieldValuesCommand extends Command
|
||||
}
|
||||
|
||||
$currentValue = $currentValuesByFieldId[$definition->getId()] ?? null;
|
||||
$issue = null;
|
||||
$issue = null;
|
||||
|
||||
if (!$currentValue instanceof CustomFieldValue) {
|
||||
$issue = 'missing';
|
||||
|
||||
@@ -21,13 +21,13 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use function ksort;
|
||||
use function preg_replace;
|
||||
use function sprintf;
|
||||
use function str_starts_with;
|
||||
use function strlen;
|
||||
use function strtolower;
|
||||
use function trim;
|
||||
|
||||
@@ -110,20 +110,20 @@ final class RestorePieceCustomFieldValuesCommand extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
$currentValue = $currentValuesByFieldId[$definition->getId()] ?? null;
|
||||
$currentValue = $currentValuesByFieldId[$definition->getId()] ?? null;
|
||||
$shouldRestore = null === $currentValue || '' === trim($currentValue->getValue());
|
||||
if (!$shouldRestore) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$candidate = $historicalValues[$normalizedName];
|
||||
$candidate = $historicalValues[$normalizedName];
|
||||
$plannedRows[] = [
|
||||
$definition->getName(),
|
||||
$candidate['value'],
|
||||
$candidate['sourceDate'],
|
||||
$currentValue ? 'update-empty' : 'create-missing',
|
||||
];
|
||||
$changesCount++;
|
||||
++$changesCount;
|
||||
|
||||
if (!$apply) {
|
||||
continue;
|
||||
@@ -186,7 +186,7 @@ final class RestorePieceCustomFieldValuesCommand extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
$rawName = trim(substr($field, \strlen('customField:')));
|
||||
$rawName = trim(substr($field, strlen('customField:')));
|
||||
$normalizedName = $this->normalizeFieldName($rawName);
|
||||
if ('' === $normalizedName || array_key_exists($normalizedName, $values)) {
|
||||
continue;
|
||||
@@ -198,9 +198,9 @@ final class RestorePieceCustomFieldValuesCommand extends Command
|
||||
}
|
||||
|
||||
$values[$normalizedName] = [
|
||||
'value' => $candidate,
|
||||
'sourceDate' => $log->getCreatedAt()->format('Y-m-d H:i:s'),
|
||||
'sourceField'=> $rawName,
|
||||
'value' => $candidate,
|
||||
'sourceDate' => $log->getCreatedAt()->format('Y-m-d H:i:s'),
|
||||
'sourceField' => $rawName,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ final class RestoreRecoverablePieceCustomFieldValuesCommand extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
$pieceCount++;
|
||||
++$pieceCount;
|
||||
$changesCount += count($pieceRows);
|
||||
$rows = [...$rows, ...$pieceRows];
|
||||
}
|
||||
@@ -169,8 +169,8 @@ final class RestoreRecoverablePieceCustomFieldValuesCommand extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
$currentValue = $currentValuesByFieldId[$definition->getId()] ?? null;
|
||||
$shouldRestore = null === $currentValue || '' === trim($currentValue->getValue());
|
||||
$currentValue = $currentValuesByFieldId[$definition->getId()] ?? null;
|
||||
$shouldRestore = null === $currentValue || '' === trim($currentValue->getValue());
|
||||
if (!$shouldRestore) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user