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
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | no_encryption_method_description.patch-2984719-3.patch | 1.33 KB | th_tushar |
| #2 | no_encryption_method_description.patch-2984719-2.patch | 1.33 KB | cellar door |
Issue fork encrypt-2984719
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
Comment #2
cellar door commentedPatch included (my IDE sometimes messes up the tabs/spacing so may need final cleanup before merging)
Comment #3
th_tushar commentedFixed coding standards issue.
Comment #6
ptmkenny commentedMade an MR of patch #3 so that this can be tested against GitLab CI.
Comment #7
benstallings commentedClaude 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.
Comment #8
ptmkenny commented@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.
Comment #9
benstallings commented@ptmkenny, thank you for the feedback!
Comment #10
benstallings commentedComment #11
ptmkenny commented"Needs work" as the MR does not pass cleanly.
Comment #12
benstallings commented@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.
Comment #14
alexpottAdded a review comment.
Comment #15
ptmkenny commentedOk, 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?)
Comment #16
ptmkenny commentedComment #17
alexpott@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.
Comment #18
ptmkenny commentedComment #19
ptmkenny commentedOk, I reverted the change. I think we can keep the existing behavior; we may revisit this in 4.0 if we make API changes.
Comment #21
ptmkenny commented