Comments

JeroenT created an issue. See original summary.

jeroent’s picture

Status: Active » Needs review
StatusFileSize
new7.09 KB

Started working on this issue. Had limited time so I did not make a lot of progress, but started grouping logic into separate functions and replaced the usage of $form_state with a variable that was declared earlier in the function.

The separate functions should also be converted to a service or multiple services imo.

jeroent’s picture

Issue summary: View changes
jeroent’s picture

Issue summary: View changes
aohrvetpv’s picture

Looks good!

This code (which you didn't change so far) is mystifying to me:

  $expiration = $form_state->getValue('field_password_expiration');
  if (!is_null($expiration) && $expiration['value'] === FALSE) {
    $form_state->setValue('field_password_expiration', ['value' => 0]);
  }

I'm not sure what that has to do with validation. It looks like it's turning a FALSE (checkbox unchecked) into a 0 for storage in the database or something. Seems like maybe it should be a submit handler thing, and not in the _password_policy_constraints_validate(), but maybe I am missing the purpose. I'll git blame it later and see if that yields any clues.

jeroent’s picture

StatusFileSize
new12.58 KB
new8.35 KB

Had some time to work on this issue. Created a new version and made 2 separate functions, one for validation and one for building the table.

jeroent’s picture

StatusFileSize
new12.5 KB
jeroent’s picture

Allright, so tests are still passing. Did some manual testing of this patch and everything seems to work as before.

Next steps are:

  • Moving $form, and $form_state out of these functions
  • Move to a separate service.
jeroent’s picture

StatusFileSize
new17.11 KB
new16.93 KB

Moved the code to a separate service.

jeroent’s picture

StatusFileSize
new25.49 KB

Removed $form, and $form_state from the validation and table methods.

jeroent’s picture

StatusFileSize
new20.31 KB

Status: Needs review » Needs work

The last submitted patch, 10: 3064853-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

aohrvetpv’s picture

Unsure why it's failing tests, but this looks terrific!

jeroent’s picture

Status: Needs work » Needs review
StatusFileSize
new30.94 KB
new5.5 KB

@AohRveTPV,

The tests are failing because I made some changes to the validation plugins. Instead of passing an array $user_context, the user entity is now added. Changed the tests accordingly.

Status: Needs review » Needs work

The last submitted patch, 14: 3064853-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jeroent’s picture

Status: Needs work » Needs review
StatusFileSize
new30.95 KB
new458 bytes
aohrvetpv’s picture

Hope to review/test this soon. Sorry for the delay, I had a problem with my Drupal development VM which I've now fixed.

aohrvetpv’s picture

Updated patch to apply on latest code.

Sorry for the extreme delay on reviewing/testing this.

aohrvetpv’s picture

Status: Needs review » Needs work

Bad patch in #18. Working on it.

aohrvetpv’s picture

Status: Needs work » Needs review
StatusFileSize
new2.83 KB
new30.86 KB

This patch fixes some minor issues:
- Remove unused variable $role_key.
- Change some function comments to third-person singular per documentation standards.
- Remove erroneous @return documentation.
- Remove changes unrelated to this issue (e.g., reordering use statements).

Note that interdiff versus #16 is not a pure interdiff because I first changed #16 to apply to latest -dev.

aohrvetpv’s picture

Couple more minor improvements:
- Add some missing function documentation.
- Improve variable name.

Status: Needs review » Needs work

The last submitted patch, 21: password_policy-8.x-3.x-refactor_constraints_validation-3064853-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

aohrvetpv’s picture

Status: Needs work » Needs review
StatusFileSize
new30.91 KB
new882 bytes

Forgot to change variable name in a place in #21. Trying again.

aohrvetpv’s picture

Committing without review/testing of #23, since it's minor changes versus #16 and the module is still in alpha.

aohrvetpv’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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