[ansi-sql compliant updates] - postgresql/mssql/mysql/sqlite password_policy_update_8304

Created on 3 October 2022, about 2 years ago
Updated 8 April 2024, 7 months ago

Problem/Motivation

There was an issue where duplicate rows were added to the password_policy_history table that was fixed here:

#3095980: Password history policy inserts password twice in password_policy_history table

but it did not include an update hook to remove the existing duplicates. An update hook was added to do this here:

📌 Create hook_update to remove duplicated entries in password_policy_history Fixed

but it doesn't work for some databases and thus people are seeing errors like below.

An attempt was made to restructure the query to support all databases but this has proved difficult so the final approach is to just delete all the history. Not ideal, but will work for all databases. All new data in the table should not contain duplicates because the above fix.

Original description:

Drupal 9.4.8
Postgresql 12.x
password policy version 3.2

password_policy 3.1 works fine, but upgrading to password_policy 3.2 fails as follows:

>  [error]  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "t1"
> LINE 1: DELETE t1 FROM "password_policy_history" t1 INNER JOIN "pass...
>                ^: DELETE t1 FROM "password_policy_history" t1 INNER JOIN "password_policy_history" t2 WHERE t1.id < t2.id AND t1.pass_hash = t2.pass_hash AND t1.timestamp = t2.timestamp; Array
> (
> )

Steps to reproduce

Postgresql v12, upgrading versions of dependencies

Proposed resolution

1. Update the update hook to delete all data from the table.

2. For those who've already run the update hook, they can manually remove the data from the table or run the new update hook once this code has been committed and they are using the updated module.

Remaining tasks

  • Update code
  • Review and test
  • Commit

User interface changes

User will not see error when updating to new version with any database.

API changes

Data model changes

Old data will be removed but the data model is not changing.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇨🇦Canada joseph.olstad

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024