Fix deprecated code usage

Created on 2 March 2024, about 1 year ago
Updated 6 August 2024, 8 months ago

Problem/Motivation

When we enabled Drupal.org's GitLab CI support in commit 36847a0, it started running PHPStan on the code.

PHPStan has pointed out some deprecated function usages in the code:

  1. Call to deprecated function user_roles() in sitemap.install (1 usage)
  2. Use of deprecated trait \Drupal\Tests\field\Traits\EntityReferenceTestTrait in class \Drupal\Tests\sitemap\Functional\SitemapTaxonomyTestBase (thrown in tests/src/Functional/SitemapTaxonomyTestBase.php, 1 usage)

Proposed resolution

Replace these uses of deprecated code according to PHPStan suggestions. Remove them from phpstan-baseline.neon.

Remaining tasks

  1. See 📌 Drupal 11 compatibility fixes for sitemap Fixed

User interface changes

None.

API changes

None.

Data model changes

None.

📌 Task
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

🇨🇦Canada mparker17 UTC-4

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

Comments & Activities

  • Issue created by @mparker17
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sarwan_verma

    Hi @mparker17,
    I have fixed this issue " Fix deprecated code usage" and also attached patch,
    please review and verify.

  • Status changed to Needs work about 1 year ago
  • 🇨🇦Canada mparker17 UTC-4

    @sarwan_verma, thank you very much for the quick response!

    Your patch looks great, but, there are two things to do before I will merge it...

    1. You must remove lines 58-65 and lines 3-12 from phpstan-baseline.neon, otherwise PHPStan will throw 2 new errors, saying something like "I was told to ignore this deprecated code, but I can't any deprecated code" (I'm paraphrasing a bit).

    2. Because Drupal CI doesn't run Rector yet, we aren't testing against Drupal 11, and Drupal 11 is still very much in active development, as a maintainer, I don't feel confident saying "it's compatible with Drupal 11". This will change as Drupal 11 gets closer to release, but it isn't appropriate to say that right now. So, please delete the part of your patch that changes the core_version_requirement in sitemap.info.yml.

    ... When these two things are done, I will be happy to apply your patch and credit you and Virasat Solutions!

    If you'd like me to explain a little bit more about why I have made each of those requests, I can go into more detail. Thank you very much again for your quick response!

  • Status changed to Closed: duplicate 8 months ago
  • 🇨🇦Canada mparker17 UTC-4

    These were both done in 📌 Drupal 11 compatibility fixes for sitemap Fixed so I'm closing this as a duplicate of that one.

Production build 0.71.5 2024