Problem/Motivation
Since 4.0.1, I have an issue because I'm not using Masquerade on my Drupal install.
Steps to reproduce
Install Password Policy, without installing Masquerade.
Uncaught PHP Exception Error: "Call to undefined method Symfony\Component\HttpFoundation\RequestStack::isMasquerading()" at /web/modules/contrib/password_policy/src/EventSubscriber/PasswordPolicyEventSubscriber.php line 118
Proposed resolution
I don't know why, but on my install where I don't have Masquerade, $masquerade variable in constructor is returning a variable and not NULL.
var_dump on this variable gives me an object of this class:
Symfony\Component\HttpFoundation\RequestStack
One way to solve it would be to check the variable before to initialize it in PasswordPolicyEventSubscriber, line 71:
$this->masquerade = $masquerade && class_exists('\\Drupal\\masquerade\\Masquerade') && $masquerade instanceof \Drupal\masquerade\Masquerade ? $masquerade : NULL;
Remaining tasks
Nothing
User interface changes
Nothing
API changes
Nothing
Data model changes
Nothing
Thank you for your work.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | password_policy-3439398.patch | 684 bytes | sarwan_verma |
Comments
Comment #2
sarwan_verma commentedHi @relisiuol,
I have fixed this issue "Password Policy & Masquerade support" and also attached patch,
kindly review and verify .
Comment #3
relisiuol commentedHi sarwan_verma,
Sadly your fix is not working because, as I said in my report, $masquerade variable in constructor is not null.
BUT, after cleaning drupal cache everything went back to normal.
Best regards,
Comment #4
relisiuol commentedComment #5
pratishjha commentedThe patch is not working. Still getting the error
Do we have any solution for this?
Comment #6
NvisionSA commentedHi pratishjha,
I have the same error as yours.
I just ran:
composer require 'drupal/masquerade:^2.0@RC'and that solves my problem
Comment #7
canardesign commentedNot working for me either, should we downgrade password_policy ?
Comment #8
dianacastillo commentedrunning composer require 'drupal/masquerade:^2.0@RC' worked for me as in #6 thanks