Instead of providing a default encryption method, let's update the description on the form when no encryption method is present to make sure the user is pointed to the docs (which I've recently migrated to the d8 handbook here: https://www.drupal.org/docs/8/modules/encrypt ).

The way I've got in the patch will update the description. The other method I toyed with is replacing the select element entirely with just a markup that has the explanation.

2 things to consider:

1. Right now encryption method isn't a required field, should we require this so the form errors if nothing is selected?
2. Should we do the same for the keys, explaining how to create secure keys (mentioned in the issue here: https://www.drupal.org/project/encrypt/issues/2863424)

Patch incoming

Issue fork encrypt-2984719

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

Cellar Door created an issue. See original summary.

cellar door’s picture

Patch included (my IDE sometimes messes up the tabs/spacing so may need final cleanup before merging)

th_tushar’s picture

Status: Active » Needs review
StatusFileSize
new1.33 KB

Fixed coding standards issue.

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

ptmkenny’s picture

Made an MR of patch #3 so that this can be tested against GitLab CI.

benstallings’s picture

Status: Needs review » Needs work

Claude Code says:

Issues Found

1. Inconsistent indentation — uses tabs instead of spaces

The Drupal coding standard requires 2-space indentation. The new code uses tabs (visible in the diff and the file), while the surrounding code uses spaces. Lines 154–163 all use tab indentation.

2. Inconsistent internal alignment

The array keys inside the $this->t() call have irregular alignment:
- '@module-page' is indented with 5 tabs
- '@docs-link' is indented with 4 tabs + 2 spaces
- The closing ] and ) are at yet another level

3. Documentation link may be outdated

The docs link https://www.drupal.org/docs/8/modules/encrypt references "Drupal 8" specifically. Given this project targets Drupal 10+ (per recent commits), the URL should be verified — Drupal.org may have updated its docs structure.

4. The #required => TRUE still applies when there are no options

When $method_options is empty, the select element is still rendered with #required => TRUE and no options. This means the form can't be submitted. The description tells the user to go install a module, but the form remains in a broken/unsubmittable state. Consider either:
- Disabling the form element ('#disabled' => TRUE) when empty, or
- Adding an '#empty_option' to make the UX clearer.

5. Minor: @module-page URL is generic

The link https://www.drupal.org/project/encrypt points to the Encrypt project page itself, not to a list of encryption method modules. A link to something like the Real AES or Sodium module pages (or a docs section listing recommended methods) would be more actionable for the user.

Verdict

The intent is good — users currently get no guidance when no encryption methods are installed. The main things to fix before merging are the tab indentation (should be 2 spaces per Drupal standards) and considering the UX when the select has no options.

ptmkenny’s picture

@benstallings There may be issues with the PR, but if you're posting an AI "code review", I think at a minimum you should post the prompt you used, the version of Claude, and also what YOU think as a human. As the poster, you should be vetting Claude's response, not changing issue status without anything other than an AI-generated comment.

benstallings’s picture

Assigned: Unassigned » benstallings

@ptmkenny, thank you for the feedback!

benstallings’s picture

Assigned: benstallings » Unassigned
Status: Needs work » Needs review
ptmkenny’s picture

Status: Needs review » Needs work

"Needs work" as the MR does not pass cleanly.

benstallings’s picture

Status: Needs work » Needs review

@ptmkenny, none of the failing tests relate to the file that is changed here.

- phpcs: 1 error in encrypt.links.action.yml (extra trailing newline) + 1 warning in encrypt.info.yml (version key) — unrelated files.
- phpstan: Errors in src/Commands/EncryptCommands.php (Drush base class not found) and non-static @dataProvider methods in two test files — unrelated files.
- phpunit: 2 errors, both from the same non-static @dataProvider issue (PHPUnit 10+ requires static data providers) in EncryptServiceTest.php and EncryptionProfileTest.php — unrelated files.

I confirmed via git diff 8.x-3.x that all three implicated files are byte-identical to the base branch, so these are pre-existing issues, not regressions from this branch. No fixes needed here.

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

alexpott’s picture

Status: Needs review » Needs work

Added a review comment.

ptmkenny’s picture

Status: Needs work » Needs review

Ok, we now show a warning but do not change the description (other than a period, which I think is more consistent with Drupal in general?)

ptmkenny’s picture

alexpott’s picture

@ptmkenny if we're not going change the #required value then perhaps we should make it an error as you won't be able to save the form until this is fixed.

ptmkenny’s picture

Status: Needs review » Needs work
ptmkenny’s picture

Status: Needs work » Needs review

Ok, I reverted the change. I think we can keep the existing behavior; we may revisit this in 4.0 if we make API changes.

  • ptmkenny committed b8f53da3 on 8.x-3.x
    fix: #2984719 Point users to docs when no encryption method is installed...
ptmkenny’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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