Problem/Motivation

auto_username.settings contains the line: aun_case: AUN_CASE_LEAVE_ASIS. AUN_CASE_LEAVE_ASIS is a constant in PHP, but it will be seen as a string in YML files. This means that on install, neither value for the "Character case" radio buttons is chosen. It is supposed to default to the first item.

Steps to reproduce

View admin/config/people/accounts/patterns after install. Export config and see that aun_case is replaced with 0.

Proposed resolution

Use 0 instead of AUN_CASE_LEAVE_ASIS in auto_username.settings.

Remaining tasks

Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Liam Morland created an issue. See original summary.

liam morland’s picture

Assigned: liam morland » Unassigned
Status: Active » Needs review
jayelless’s picture

Related issues: +#3391633: Fix phpcs issues

@Liam Morland: is this still a problem now that #3391633: Fix phpcs issues has been committed?

liam morland’s picture

I am not familiar with the !php/const syntax, but it looks plausible. If it does what it appears to do, then it will fix this.

Edit: I am no longer working on a project that uses this, so I have no easy way of testing myself.

adiatis’s picture

I got this error on update drupal or install new module:

Drupal\Core\Config\UnsupportedDataTypeConfigException: Invalid data type in config auto_username.settings, found in file modules/contrib/auto_username/config/install/auto_username.settings.yml: The string "!php/const Drupal\auto_username\AutoUsernamePunctuationOptions::CASE_LEAVE_AS_IS" could not be parsed as a constant.

I installed lastest dev version but #3391633 didn't solved the problem.

I changed

aun_case: !php/const Drupal\auto_username\AutoUsernamePunctuationOptions::CASE_LEAVE_AS_IS

to

aun_case: 0

error is gone.

jibus’s picture

Priority: Minor » Major
Status: Needs review » Reviewed & tested by the community

Got error when enabled the module :

Drupal\Core\Config\UnsupportedDataTypeConfigException: Invalid data type in config auto_username.settings, found in file modules/contrib/auto_username/config/install/auto_username.settings.yml: The string "!php/const Drupal\auto_username\AutoUsernamePunctuationOptions::CASE_LEAVE_AS_IS" could not be parsed as a constant. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser? at line 5 (near "aun_case: !php/const Drupal\auto_username\AutoUsernamePunctuationOptions::CASE_LEAVE_AS_IS") in Drupal\Core\Config\FileStorage->read() (line 118 of /var/www/website/web/core/lib/Drupal/Core/Config/FileStorage.php).

Set aun_case: 0 in auto_username.settings.yml fixed the issue.

Switch to major since this module cannot be installed.

kris77’s picture

Set aun_case: 0 in auto_username.settings.yml fixed the issue for me too.

Thanks @adiatis @Jibus

sorlov made their first commit to this issue’s fork.

sorlov’s picture

rebased branch from latest 8.x-1.x, so now MR can be merged

leducdubleuet’s picture

Cannot install the module without this patch on Drupal 10.3.6.

Thank you.

blacksnipe’s picture

Bumped into this one, too and the fix indeed solves it.
+1 for RTBC.

In the meantime, a bump for this fix to be merged in the next stable release.

4kant’s picture

Thank you for #9!

jayelless’s picture

Status: Reviewed & tested by the community » Fixed
liam morland’s picture

Do we not still need the fix in the merge request?

jayelless’s picture

@Liam morland. The value is set to zero in the yml file, while the original string is retained as a comment that can be reinstated when the core issue lands.

jayelless’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.