Problem/Motivation
Can't add constraint.
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/config/system/password_policy/constraint/add/default/character_types?ajax_form=1
StatusText: parsererror
ResponseText: Error: Call to a member function getConstraints() on null in Drupal\password_policy\Form\ConstraintEdit->submitForm() (line 145 of /var/www/html/web/modules/contrib/password_policy/src/Form/ConstraintEdit.php)."
Steps to reproduce
Install password policy. Install Password Character Types Policy and Password Characters of Type Policy. Add Policy and try to add constraint.
Go to the logs and you will see this message:
Error: Call to a member function getConstraints() on null in Drupal\password_policy\Form\ConstraintEdit->submitForm() (line 145 of /app/web/modules/contrib/password_policy/src/Form/ConstraintEdit.php)
Comments
Comment #2
danthorneComment #3
adriancidComment #4
adriancidComment #5
adriancidI have the module installed on two different sites and in one of them I have the problem with version 3.1.0 and dev and Drupal 9.4.2 and in the other with version 3.1.0 and Drupal 9.3.16 is working I don't know if it is related to the Drupal version or it is related to another module causing the problem.
Comment #6
danthorneMy version of Drupal with the issue is Drupal 9.4.2
Comment #7
fskreuz commentedThe issue is that ctools switched from shared tempstore in 3.7 to private tempstore in 3.8 to fix a concurrent edit issue. This caused issues on dependent modules (e.g. password_policy, page_manager, etc.) that explicitly use
tempstore.shared. The issue is because tempstore.shared cannot read entries added by tempstore.private, the cached values are present but cannot be read.The quick fix for now is to pin your ctools version to 3.7.
The longer term fix is to remove ctools dependency (see https://www.drupal.org/project/password_policy/issues/2877040)
If you're adventurous, attached is a patch that switches tempstore.shared to tempstore.private for password_policy. Do note that the ctools fix done in 3.8 is somewhat incomplete, as it only switched storages for a certain portion of ctools. There might still be cases within ctools where it stores data with one but tries to read with the other, the attached patch might still not work (I ended up patching ctools to use tempstore.private for all the things).
Comment #8
adriancidThe patch fix the problem and now I'm able to add the policies.
Comment #9
adriancidI don't know if is related but I'm able to create the policies but they are not visible in the user registration form
Comment #10
adriancidSorry is working, I added the policies in Dev and was checking on my local :-D LOL
Comment #11
paulocsHello, can you confirm if you are still having this issue in the dev branch?
We have removed the ctools dependency in #2877040: Remove dependency on CTools
Comment #12
vselivanovWorks for me with Drupal 9.4, Ctools 3.11 and Password Policy 3.x-dev. Dependency was removed and error fixed.
Comment #13
paulocsSo moving to fixed. New releases will come soon. #3305839: Create Password Policy 8.x-3.2 release