Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I have simplenews installed. When opening simplenews pane on user profile, I get a fatal error from password policy:
Recoverable fatal error : Argument 1 passed to password_policy_password_element_alter() must be of the type array, null given, called in /home/oturpin/equidrup/sites/all/modules/password_policy/password_policy.module on line 261 and defined dans password_policy_password_element_alter() (ligne 201 dans /home/oturpin/equidrup/sites/all/modules/password_policy/password_policy.module).
Comment | File | Size | Author |
---|---|---|---|
#16 | password_policy-7.x-2.x-fix_element_alter_error-2489918-16.patch | 2.78 KB | Anonymous (not verified) |
#4 | password_policy-7.x-2.x-fix_element_alter_error-2489918-4.patch | 1.41 KB | AohRveTPV |
#1 | password_policy-7.x-2.x-fix_element_alter_error-2489918-1.patch | 483 bytes | AohRveTPV |
Comments
Comment #1
AohRveTPV CreditAttribution: AohRveTPV commentedDoes this change fix the problem?
Comment #2
oturpin CreditAttribution: oturpin commentedHi AohRveTPV,
So quick !!! Much better. Pb solved.
Thx
Comment #3
AohRveTPV CreditAttribution: AohRveTPV commentedOK, great. I will plan to develop a better fix for commit.
The code was always trying to customize the password field for the
user_register_form
anduser_profile_form
, whether or not the password field existed on them.Comment #4
AohRveTPV CreditAttribution: AohRveTPV commentedSame fix, but try to make code intent more explicit.
Comment #5
oturpin CreditAttribution: oturpin commentedHi AohRveTPV,
Don't know if any link with database type... I am using Postgresql. Fix is OK for me.
Thx
Comment #7
AohRveTPV CreditAttribution: AohRveTPV commentedComment #8
ron_s CreditAttribution: ron_s commentedThis same problem exists with the Profile2 module. Looking at the patch, I'm wondering if there's a simpler way that it could be done, without hard coding
user_profile_form
anduser_register_form
in the code?How about just setting the default array value to
NULL
, and skipping the function if no array is set. Seems more straightforward to me, unless I'm missing some particular case?:Comment #9
ron_s CreditAttribution: ron_s commentedLooking a little more closely at the patch you created in #1, it's relatively close to what I added, except you're using a
return
to break out of the function.I'm assuming the reason for the more lengthy approach in #4 is you're wanting to be more explicit in the solution?
Comment #10
AohRveTPV CreditAttribution: AohRveTPV commentedThat would be ideal. I thought there could possibly be cases where
$form['account']['pass']
is set but the element should not be altered. (The original authors may have hard-coded the form IDs for a reason.) So adding an extra condition seemed safest initially.I'm not sure your proposed code change would work though. Have you tried it? On some forms, I believe
$form['account']
will not be set, so accessing$form['account']['pass']
in the call topassword_policy_password_element_alter()
would give an error.Comment #11
AohRveTPV CreditAttribution: AohRveTPV commentedYes, I wanted the purpose of the conditionals to be clearer. A problem I have had working with the code, especially the 1.x branch, is conditionals where it is unclear what they are doing or why they are necessary.
Comment #12
ron_s CreditAttribution: ron_s commentedI did try my suggestion with Profile2 and it worked as I would expect, however as you mentioned it may not work in all situations.
Certainly a case where
$form['account']
is not set would be an issue.Comment #14
mudjunky CreditAttribution: mudjunky commented+1 for @ron_s #8 solution. The patches did not work for me. They fixed the fatal error, but nullified the password policy. Users could enter any password they wanted without any barrier from the password policy.
Comment #15
AohRveTPV CreditAttribution: AohRveTPV commentedmudjunky, are you also using Profile2?
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedYes, with Profile2 I am receiving this error. I'm attaching a patch with the solution from #8, which fixes the problem for me.
H.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedThe patch was made against the dev version, that's why it failed the tests.
Comment #21
badjava CreditAttribution: badjava at Pfizer, Inc. commented+1 on the commit in #6. While it may not be the simplest implementation as others have suggested, it does work and should $form['account'] be unset, everything still works well. This issue appears to be resolved.
@mudjunky re: #14 - Try the dev version or use the patch from it which should apply cleanly to alpha5.
Comment #22
AohRveTPV CreditAttribution: AohRveTPV commentedI believe this is fixed in 7.x-2.0-alpha6 and onward, without hard-coding form IDs, by the patch committed in #2562481: Apply password policies to account password elements on custom forms:
http://cgit.drupalcode.org/password_policy/commit/?id=9f69062
If you experienced this error before, please retest with 7.x-2.0-alpha6 or later, and let us know whether it still occurs. If so, we can re-open. Thanks all.