Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to restrict the length of generated sql:sanitize data #6190

Open
robme opened this issue Jan 3, 2025 · 2 comments
Open

Ability to restrict the length of generated sql:sanitize data #6190

robme opened this issue Jan 3, 2025 · 2 comments

Comments

@robme
Copy link

robme commented Jan 3, 2025

Is your feature request related to a problem? Please describe.
I've used sql:sanitize on a basic Drupal Commerce site, and it filled in user fields with random data. Two of the fields are for first name and last name and the data it generates is not appropriate. For example, everyone's name is:

Autem decet nostrud quis sagaciter suscipere. Cui hendrerit in iusto luptatum probo vereor. Abluo adipiscing aliquam appellatio augue bene magna nibh tation ut. Abbas causa eu singularis. Abbas iusto minim voco. Accumsan huic nutus refero tincidunt. Commodo exerci molior praemitto qui. Bene cui defui facilisis nulla sagaciter sed suscipere usitas volutpat.

The first name is also used in hook_user_format_name_alter() and this means the admin toolbar is broken because it has this large paragraph of text over the top of it.

Describe the solution you'd like
My idea is an option passed which lets you specify fields which should not fill the full length.

Describe alternatives you've considered
There may be better ways of having more precise control over the data per field but I am not sure how that would work.

Additional context
Add any other context or screenshots about the feature request here.

@robme
Copy link
Author

robme commented Jan 3, 2025

I implemented my idea here on 12.x which can be seen in this PR: robme#1

Not sure how common this might be or whether more granular control could be done - like something similar to a regex to say what type of data should go in each field.

@weitzman
Copy link
Member

weitzman commented Jan 4, 2025

It is the responsibility of the field type (i.e. text) to generate a sample value and to respect the max/min and such. See

$value_array = $field_type_class::generateSampleValue($def);
. Maybe there is a bug here for your field type and configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants