Drupal 11 compatibility fixes

Created on 19 December 2024, about 1 month ago

Problem/Motivation

Hello project maintainers,
This is an issue to help make this module compatible with Drupal 11.
Patches will periodically be added to this issue that remove Drupal 11 deprecated method getEntityTranslation() of class Drupal\views\Plugin\views\field\LinkBase and default_argument_skip_url.

Proposed resolution

Use Drupal\views\Entity\Render\EntityTranslationRenderTrait::getEntityTranslationByRelationship instead of getEntityTranslation()

Remove default_argument_skip_url in config/optional/views.view.masquerade_as.yml

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇨🇦Canada nghua

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

Merge Requests

Comments & Activities

  • Issue created by @nghua
  • Pipeline finished with Failed
    about 1 month ago
    Total: 155s
    #373912
  • 🇨🇦Canada nghua

    I think my merge request is ready for review now, I know there are failing tests but they were failing before my patch.

  • 🇨🇦Canada nghua

    (unassigned myself)

  • Pipeline finished with Failed
    about 1 month ago
    Total: 170s
    #375326
  • Pipeline finished with Failed
    about 1 month ago
    Total: 155s
    #375394
  • 🇨🇦Canada mparker17 UTC-4

    I've reviewed the code changes in the merge request, and it looks good to me.

    I ran some manual tests (documented below) of the basic functionality on the code in !4 and Drupal 11, and I was able to get it to work.

    Here's what I did to test !4...

    1. Install ddev (I tested on version 1.24.1)
    2. Clone the module, issue fork, and branch:
      1. git clone --branch '2.x' https://git.drupalcode.org/project/masquerade_field.git && cd masquerade_field/ - clone the project
      2. git remote add masquerade_field-3495033 git@git.drupal.org:issue/masquerade_field-3495033.git && git fetch masquerade_field-3495033 - add a remote for the issue fork
      3. git checkout -b '3495033--drupal-11' --track masquerade_field-3495033/'3495033--drupal-11' - switch to the branch for merge request !4
    3. Set up a test site for the module with the ddev/ddev-drupal-contrib plugin:
      1. ddev config --project-type=drupal --docroot=web --php-version=8.3 --corepack-enable --project-name=masquerade-field - create a ddev project for testing the module
      2. ddev add-on get ddev/ddev-drupal-contrib && ddev start && ddev poser && ddev symlink-project - run the setup steps for the ddev/ddev-drupal-contrib addon
      3. Go to https://masquerade-field.ddev.site/core/install.php in a browser. Confirm that I saw the Drupal 11.1.0 installer. Install the site with the "Standard" install profile.
      4. Go to /admin/people/create and create a user with the Content editor role. I gave mine the username test_editor.
      5. Go to /admin/people/create and create a user with the Authenticated role. I gave mine the username test_user.
    4. Set up the module for testing:
      1. Go to /admin/modules and install masquerade_field and its dependencies
      2. Go to /admin/people/permissions, grant the Content editor role the following permissions:
        • Masquerade Field -> Edit the masquerade field
        • Masquerade Field -> View any masquerade field
        • Masquerade Field -> View own masquerade field
        • User -> View user information

        ... click Save permissions

    5. Test the basic module functions in Drupal 11:
      1. Log out of the administrator account, and log in as the test_editor Content editor user created earlier.
      2. Go to the edit tab for the test_editor account (on my test site, it was at /user/2/edit). You see a Masquerade as field.
      3. Enter test_editor into the Masquerade as autocomplete, and select it from the autocomplete drop-down (on my test site, that made it say test_editor (2).
      4. Click Save at the bottom of the page.
      5. You see the error message User test_editor cannot masquerade as itself.
      6. Enter test_user into the Masquerade as autocomplete, and select it from the autocomplete drop-down (on my test site, that made it say test_user (3))
      7. Click Save at the bottom of the page.
      8. You see the status message The changes have been saved.
      9. Click the View tab at the top of the page.
      10. You see a Masquerade as field, with a link to masquerade as test_user.
      11. Click the test_user link to masquerade as the test_user.
      12. You see the status message You are now masquerading as test_user.
      13. Click the Unmasquerade link in the site header. If you can't see it, you may need to click the Menu button in the top-right corner of the page. If you're not using the Olivero theme, the Unmasquerade link may be located elsewhere.
      14. You see the status message You are no longer masquerading as test_user.
    6. Make sure there are no errors being logged:
      1. Log out of the test_editor user created earlier; and log in as the administrator again
      2. Go to /admin/reports/dblog to ensure our setup/testing did not result in any error messages related to this module.
Production build 0.71.5 2024