Password Policy & Masquerade support

Created on 8 April 2024, 7 months ago
Updated 29 April 2024, 7 months ago

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.

🐛 Bug report
Status

Closed: works as designed

Version

4.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @relisiuol
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • 🇮🇳India sarwan_verma

    Hi @relisiuol,

    I have fixed this issue "Password Policy & Masquerade support" and also attached patch,
    kindly review and verify .

  • Hi sarwan_verma,

    Sadly your fix is not working because, as I said in my report, $masquerade variable in constructor is not null.

    Best regards,

  • Status changed to Closed: works as designed 7 months ago
  • 🇮🇳India pratishjha

    The patch is not working. Still getting the error

    The website encountered an unexpected error. Please try again later.
    Error: Call to undefined method Drupal\Core\Http\RequestStack::isMasquerading() in Drupal\password_policy\EventSubscriber\PasswordPolicyEventSubscriber->checkForUserPasswordExpiration() (line 118 of modules\contrib\password_policy\src\EventSubscriber\PasswordPolicyEventSubscriber.php).

    Do we have any solution for this?

  • Hi pratishjha,

    I have the same error as yours.
    I just ran:
    composer require 'drupal/masquerade:^2.0@RC'
    and that solves my problem

  • 🇫🇷France canardesign Montpellier

    Not working for me either, should we downgrade password_policy ?

Production build 0.71.5 2024