Drupal 9 Compatibility audit tasks

  1. Run Drupal Check on the latest 8.x branch to find deprecated code
  2. Run Drupal Rector on the module to automate some D9 compatibility

Deprecated code status:

Drupal 9 Compatibility checklist
- [ ] An automatable test exists that can be run against the Drupal core 9.x branch to verify minimum compatibility
- [ ] No Drupal 9-deprecated code deprecated exists in the codebase per drupal-check
- [x] The info.yml file meets Drupal 9 syntax requirements (Add core_version_requirement: ^8 || ^9, unless additional specificity is required (see https://www.drupal.org/node/3070687))
- [x] “Drupal 9 porting info” exists on the project page

Comments

oheller created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new20.46 KB

Here is the patch, please review.

anavarre’s picture

Issue summary: View changes
Status: Needs review » Needs work

Updating the issue because I'm seeing many more deprecation notices with 8.x-4.x. Speaking of which, shouldn't we target 8.x-3.x since it's the current recommended release?

kristen pol’s picture

Issue tags: +Drupal 9 compatibility

Per a Slack discussion with Gábor Hojtsy regarding usage of D9 tags (Drupal 9, Drupal 9 compatibility, Drupal 9 readiness, etc.), "Drupal 9 compatibility" should be used for contributed projects that need updating and "Drupal 9" was the old tag for D8 issues before the D9 branch was ready. Doing tag cleanup here based on that discussion.

shubhangi1995’s picture

Assigned: Unassigned » shubhangi1995
lilit_ghazaryan’s picture

StatusFileSize
new22.62 KB
new2.47 KB
swatichouhan012’s picture

Assigned: shubhangi1995 » Unassigned
StatusFileSize
new23.64 KB
new11.1 KB

I have fixed most of the deprecated errors , kindly review the patch.

swatichouhan012’s picture

Status: Needs work » Needs review
shubhangi1995’s picture

Assigned: Unassigned » shubhangi1995
shubhangi1995’s picture

There are errors in applying the patch, please rectify them.
It seems few core files too have been patched up , and are having issue applying patch please check again.

shubhangi1995’s picture

Assigned: shubhangi1995 » Unassigned
Status: Needs review » Needs work
swatichouhan012’s picture

Status: Needs work » Needs review
Issue tags: +VbContribution2020
StatusFileSize
new23.64 KB

Hi @shubhangi1995 thanks for review patch, i am attaching new patch.

nedjo’s picture

Status: Needs review » Needs work

Thanks all for your work on these updates.

Below are a few places where we could be injecting services. Because we are changing existing services, we also need a new empty update that will trigger a container rebuild--at least, last I knew this was needed. An example is features_update_8300():

/**
 * Rebuild the container to add a parameter to the features.manager service.
 */
function features_update_8300() {
  // Empty update to cause a cache rebuild so that the container is rebuilt.
}
  1. +++ b/modules/features_ui/src/Form/AssignmentExcludeForm.php
    @@ -60,7 +68,7 @@ class AssignmentExcludeForm extends AssignmentFormBase {
    +    $info = \Drupal::service('extension.list.$type')->getExtensionInfo('module', \Drupal::installProfile());
    

    Both the extension list and the install profile services could/should be injected.

  2. +++ b/src/Plugin/FeaturesAssignment/FeaturesAssignmentExclude.php
    @@ -66,7 +66,7 @@ class FeaturesAssignmentExclude extends FeaturesAssignmentMethodBase {
    +          $profile_name = \Drupal::installProfile();
    

    Ideally we would inject this service.

  3. +++ b/src/Plugin/FeaturesGeneration/FeaturesGenerationArchive.php
    @@ -156,9 +159,9 @@ class FeaturesGenerationArchive extends FeaturesGenerationMethodBase implements
    +    $archive_name = \Drupal::service('file_system')->getTempDirectory() . '/' . $this->archiveName;
    

    Ideally we would inject this service.

nitesh624’s picture

Issue summary: View changes
nitesh624’s picture

Version: 8.x-4.x-dev » 8.x-3.x-dev
Assigned: Unassigned » nitesh624
Issue summary: View changes
nitesh624’s picture

Status: Needs work » Needs review
StatusFileSize
new26.42 KB

Patch to remove depricated code

nedjo’s picture

Status: Needs review » Needs work

@nitesh624 thank you for your contribution.

Without further information, it is difficult for me as a maintainer to know what you've done or why.

The following would help a lot:

  • Describe the specific changes you've made compared to the previous patch. Why did you upload a new version?
  • Refer to the latest review I provided above. Have you addressed any of the remaining issues I identified? If so, which ones and how?
  • Provide an interdiff; see the relevant documentation.

Thanks!

mark_fullmer’s picture

Status: Needs work » Needs review
StatusFileSize
new18.01 KB
new13.26 KB
new11.11 KB

Since this the original deprecated code report was run over a year ago, attached is the following:

  1. 2020/04/02 Deprecated code report as generated by drupal-check on the 8.x-3.x branch: 46 errors
  2. Autogenerated fixes to deprecated code, as performed by palantirnet/drupal-rector
  3. Deprecated code report after the patch was applied: 27 errors

Perhaps these automated fixes can be committed first. Then we can focus on a more narrow amount of work for fixing the remaining items which cannot be automatically fixed.

mark_fullmer’s picture

StatusFileSize
new14.59 KB
new1.34 KB

The attached patch adds the new core_incompatible value to the Kernel test that was failing, as well as the core_version_requirement in the info.yml file, per Drupal 9 compatibility requirements.

We should still expect deprecations, but this will take care of the low-hanging fruit, and we can move onto the manual work next.

mark_fullmer’s picture

Issue summary: View changes
mark_fullmer’s picture

Issue summary: View changes
mark_fullmer’s picture

Issue summary: View changes
mark_fullmer’s picture

Issue summary: View changes
mark_fullmer’s picture

To do: Per https://www.drupal.org/pift-ci-job/1659628, the FeaturesUI test will need to be updated to not use simpletest.

  • nedjo committed c9b99c0 on 8.x-4.x authored by mark_fullmer
    Issue #3042642 by mark_fullmer: Drupal 9 Deprecated Code Report
    

  • nedjo committed 617d5b3 on 8.x-3.x authored by mark_fullmer
    Issue #3042642 by mark_fullmer: Drupal 9 Deprecated Code Report
    
nedjo’s picture

Status: Needs review » Needs work

Thanks, I've applied that initial patch, minus this part:

The attached patch adds the new core_incompatible value to the Kernel test that was failing

We can take care of that in #3122684: core_incompatible: false.

Setting to "Needs work" for the remaining D9 compatibility fixes.

nitesh624’s picture

Assigned: nitesh624 » Unassigned
Status: Needs work » Fixed
nitesh624’s picture

Status: Fixed » Reviewed & tested by the community
nitesh624’s picture

Status: Reviewed & tested by the community » Needs review
nedjo’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev
StatusFileSize
new20.44 KB

This issue has had a lot of contributors (thanks!) but not a lot of continuity between efforts, with the result that it's been hard as a maintainer to know where we stand.

If updating, please see my comment in #17.

We'll apply this to both 8.x-4.x and 8.x-3.x (which at this point are identical).

Attached is a patch that contains the portions that still apply from #12 and #16. This is very likely to fail testing.

My comments from #13 likely still mostly apply, with the difference that instead of hook_update_N() we should be using hook_post_update_NAME(). See Use hook_post_update_NAME instead of hook_update_N to clear the cache.

Setting to Needs review only to see what test failures we get.

  • nedjo committed b4f300d on 8.x-4.x
    Issue #3042642 by nedjo: Drupal 9 Deprecated Code Report
    

  • nedjo committed 8f8e70c on 8.x-3.x
    Issue #3042642 by nedjo: Drupal 9 Deprecated Code Report
    
nedjo’s picture

Status: Needs review » Needs work

The patch I posted in #31, drawing on previous work in this issue, was too broken to be of use.

I've posted a few new fixes drawing on #3140493: Automated Drupal Rector fixes supplemented with manual fixes to service injection and such.

Setting to Needs work for the (considerable) remaining work.

nedjo’s picture

Status: Needs work » Needs review
StatusFileSize
new15.95 KB

A further round of fixes to run by the test bot.

nedjo’s picture

StatusFileSize
new15.71 KB

Fix typo.

Status: Needs review » Needs work

The last submitted patch, 36: features-drupal-9-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

nedjo’s picture

Status: Needs work » Needs review

Fixes are in tests that need updating.

Applying the non-test deprecation fixes.

  • nedjo committed 02030fe on 8.x-4.x
    Issue #3042642 by nedjo: Drupal 9 Deprecated Code Report
    

  • nedjo committed 0b66926 on 8.x-3.x
    Issue #3042642 by nedjo: Drupal 9 Deprecated Code Report
    
nedjo’s picture

StatusFileSize
new3.36 KB

Status: Needs review » Needs work

The last submitted patch, 41: features-drupal-9-41.patch, failed testing. View results

nedjo’s picture

Status: Needs work » Needs review
StatusFileSize
new4.04 KB

Address some more test failures.

Status: Needs review » Needs work

The last submitted patch, 43: features-drupal-9-43.patch, failed testing. View results

nedjo’s picture

Status: Needs work » Needs review
StatusFileSize
new5.27 KB

A few more attempted fixes.

Status: Needs review » Needs work

The last submitted patch, 45: features-drupal-9-45.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • nedjo committed d499a43 on 8.x-4.x
    Issue #3042642 by nedjo, mark_fullmer, swatichouhan012, Lilit_Ghazaryan...

  • nedjo committed 33386e4 on 8.x-3.x
    Issue #3042642 by nedjo, mark_fullmer, swatichouhan012, Lilit_Ghazaryan...
nedjo’s picture

Status: Needs work » Fixed

The remaining issues appear to be tests that need updating rather than necessarily further deprecations in the module code that need fixing. Moving to a separate-follow-up issue.

  • nedjo committed 865e87e on 8.x-3.x
    Issue #3042642: register features_ui D9 compatibility
    

  • nedjo committed 2e5979f on 8.x-4.x
    Issue #3042642: register features_ui D9 compatibility
    
nedjo’s picture

Status: Fixed » Closed (fixed)

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