Problem/Motivation

I installed this module and, when try to change the configurations, I received the follow error:

The website encountered an unexpected error. Please try again later.
Error: Call to undefined function Drupal\force_password_change\Form\drupal_set_message() in Drupal\force_password_change\Form\AdminForm->submitForm() (line 364 of modules/contrib/force_password_change/src/Form/AdminForm.php).

Drupal version: 9.2.0

Steps to reproduce

1) Go to Administration -> Configuration -> People -> Force password change
2) Click in Submit button
3) You will see the error message

Proposed resolution

Change the deprecated function drupal_set_message() to \Drupal::messenger()->addMessage

Remaining tasks

User interface changes

API changes

Data model changes

Comments

larisse created an issue. See original summary.

larisse’s picture

Assigned: larisse » Unassigned
Status: Active » Needs review
StatusFileSize
new1.05 KB

I create this patch to solve this problem.

larisse’s picture

StatusFileSize
new4.29 KB

Just replacing the deprecated function in all files of module, not only in AdminForm.php, like in patch #2

hmendes’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new322.13 KB
new18.26 KB

Hello, I can confirm the problem reported and that the patch from #3 fixed the issue.
Steps:

  • Enable module
  • Go to /admin/config/people/force_password_change
  • Select a option on "Force users in the following roles to change their password"
  • Submit
  • Before: WSOD with error in the Recent log message ( print 3221131_before.png )
  • After: the form is submited with a message ( print 3221131_after.png )

Changing this to RTBC.

  • larisse committed 146a75a on 2.0.x
    Issue #3221131 by larisse, hmendes: Drupal 9 replace deprecated function...
larisse’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

jds1’s picture

Hi there! This bit us in a prod D9 site where a user was unable to log in. Patch totally fixes it. Could we please get a stable release that includes this update? Thanks!

mlncn’s picture

Ditto on the release!

Using composer require 'drupal/force_password_change:2.0.x-dev@dev' ourselves for now.

Maybe even #2922398: Unable to reset my password could be brought in right before that stable release, as a treat? :-)