Revert/Delete user revision actions cause errors

Created on 18 June 2024, 8 months ago
Updated 30 August 2024, 6 months ago

Problem/Motivation

After installing the user_revision module on a Drupal site, several type errors are encountered when managing user revisions. The issue occurs when trying to revert or delete user revisions via the provided user interface.

Steps to reproduce:

  1. Ensure your server is running PHP version 8.2.14.
  2. Install Drupal 10.2.2 using the standard installation profile.
  3. Install the user_revision module version 2.0.0-alpha1.
  4. Clear the site's cache using drush cr.
  5. Log in to the site as an administrator.
  6. Navigate to any user account (or create a new one) and edit the user by creating a new revision at /user/<user-id>/edit, then save the changes.
  7. Go to the user's revision page at /user/<user-id>/revisions.
  8. Attempt to use any of the options (Revert or Delete) for a revision.

Actual result:

There are errors.
TypeError: Drupal\user_revision\Form\UserRevisionRevertForm::__construct(): Argument #1 ($user_storage) must be of type Drupal\user_revision\Form\EntityStorageInterface, Drupal\user\UserStorage given, called in /var/www/html/web/modules/contrib/user_revision/src/Form/UserRevisionRevertForm.php on line 57 in Drupal\user_revision\Form\UserRevisionRevertForm->__construct() (line 48 of /var/www/html/web/modules/contrib/user_revision/src/Form/UserRevisionRevertForm.php).

TypeError: Drupal\user_revision\Form\UserRevisionDeleteForm::__construct(): Argument #1 ($user_storage) must be of type Drupal\user_revision\Form\EntityStorageInterface, Drupal\user\UserStorage given, called in /var/www/html/web/modules/contrib/user_revision/src/Form/UserRevisionDeleteForm.php on line 58 in Drupal\user_revision\Form\UserRevisionDeleteForm->__construct() (line 48 of /var/www/html/web/modules/contrib/user_revision/src/Form/UserRevisionDeleteForm.php).

Expected result:

The revert or delete operations should be completed without any errors.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇦Ukraine mr_fenix

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

Merge Requests

Comments & Activities

  • Issue created by @mr_fenix
  • 🇺🇦Ukraine mr_fenix

    This patch will fix the dependency and argument constructor bug.

  • 🇺🇦Ukraine mr_fenix

    This will be difficult to test because another error will appear there.

    Error: Call to a member function id() on null in Drupal\user_revision\Form\UserRevisionRevertForm->buildForm() (line 102 of /var/www/html/web/modules/contrib/user_revision/src/Form/UserRevisionRevertForm.php).

    Error: Call to a member function id() on null in Drupal\user_revision\Form\UserRevisionDeleteForm->buildForm() (line 96 of /var/www/html/web/modules/contrib/user_revision/src/Form/UserRevisionDeleteForm.php).

    Please use the same steps to reproduce it.
    The attached to this comment patch will fix it.

  • Status changed to Needs review 8 months ago
  • 🇺🇦Ukraine mr_fenix

    Unfortunately, there is a third error that will appear and prevent to test

    InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 201 of /var/www/html/web/core/lib/Drupal/Component/Datetime/DateTimePlus.php).

    The patch attached to the comment will fix this issue too.
    And as a result it will be possible to see the result of all previous fixes on UI too.

    Please use the same reproduction for the error.

  • Issue was unassigned.
  • First commit to issue fork.
  • 🇮🇳India dipakmdhrm

    All 3 patches from #3, #4 & #5 need to be applied after one another to fix this. The MR combines the patches.

Production build 0.71.5 2024