diff --git a/src/Commands/sql/sanitize/SanitizeUserFieldsCommands.php b/src/Commands/sql/sanitize/SanitizeUserFieldsCommands.php index b858e62154..c59778312f 100644 --- a/src/Commands/sql/sanitize/SanitizeUserFieldsCommands.php +++ b/src/Commands/sql/sanitize/SanitizeUserFieldsCommands.php @@ -46,7 +46,7 @@ public function getEntityFieldManager() } /** - * Sanitize string fields associated with the user. + * Sanitize string and number fields associated with the user. */ #[CLI\Hook(type: HookManager::POST_COMMAND_HOOK, target: SanitizeCommands::SANITIZE)] public function sanitize($result, CommandData $commandData): void @@ -69,7 +69,7 @@ public function sanitize($result, CommandData $commandData): void $query = $conn->update($table); $name = $def->getName(); $field_type_class = \Drupal::service('plugin.manager.field.field_type')->getPluginClass($def->getType()); - $supported_field_types = ['email', 'string', 'string_long', 'telephone', 'text', 'text_long', 'text_with_summary']; + $supported_field_types = ['email', 'string', 'string_long', 'telephone', 'text', 'text_long', 'text_with_summary', 'integer', 'decimal']; if (in_array($def->getType(), $supported_field_types)) { $value_array = $field_type_class::generateSampleValue($def); $value = $value_array['value']; @@ -98,13 +98,23 @@ public function sanitize($result, CommandData $commandData): void ]); $execute = true; break; + + case 'integer': + $query->fields([$name . '_value' => 123]); + $execute = true; + break; + + case 'decimal': + $query->fields([$name . '_value' => 123.45]); + $execute = true; + break; } if ($execute) { $query->execute(); $this->entityTypeManager->getStorage('user')->resetCache(); $this->logger()->success(dt('!table table sanitized.', ['!table' => $table])); } else { - $this->logger()->success(dt('No text fields for users need sanitizing.', ['!table' => $table])); + $this->logger()->success(dt('No text and number fields for users need sanitizing.', ['!table' => $table])); } } } @@ -112,7 +122,7 @@ public function sanitize($result, CommandData $commandData): void #[CLI\Hook(type: HookManager::ON_EVENT, target: SanitizeCommands::CONFIRMS)] public function messages(&$messages, InputInterface $input): void { - $messages[] = dt('Sanitize text fields associated with users.'); + $messages[] = dt('Sanitize text and number fields associated with users.'); } #[CLI\Hook(type: HookManager::OPTION_HOOK, target: SanitizeCommands::SANITIZE)]