Problem/Motivation

Hello project maintainers,
This is an automated issue to help make this module compatible with Drupal 9.

To read more about this effort by the Drupal Association, please read: Accelerating Drupal 9 module and theme readiness with automated patches

Periodically patches will be added to this issue that remove Drupal 9 deprecations. To stop further patches from being posted simply close this issue(any status besides Active, Needs Review or Needs work) or remove the "ProjectUpdateBotD9" tag from the issue.

The patches will be posted by the Project Update Bot official user account. This account will not receive any issue credit contributions for itself or any company.

Proposed resolution

You have a few options for how to use this issue:

  1. Accept automated patches until this issue is closed

    If this issue is left open(status of Active, Needs Review or Needs work) and the "RectorAutoPatches" tag is left on this issue, new patches will be posted periodically if new deprecations are needed.

    As the Drupal Rector project improves and is able to fix more deprecations the patches posted here will cover more of the deprecations in the module.

  2. Leave open but stop new automated patches.

    If you want to use this issue as a starting point to remove deprecations but don't want new automated patches simply leave this issue open but remove the "RectorAutoPatches" from the issue.

    You can use Drupal Rector yourself to make these patches.

    If you want to receive automated patches again simply add back the "RectorAutoPatches" tag.

  3. Close it and don't use it

    If the maintainers of this project don't find this issue useful they can simply close this issue(any status besides Active, Needs Review or Needs work) and no more automated patches will be posted here.

    If the issue is reopened then new automated patches will be posted.

    If you are using another issue(s) to work on Drupal 9 compatibility it may be useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the patch in the comment by Project Update Bot
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.

Providing feedback

If there are problems with one of the patches posted by the Project Update Bot, such as it does not correctly replace a deprecation, you can file an issue in the Rector issue queue. For other issues with the bot, for instance if the issue summary created by the bot is unclear,  use the Infrastructure project issue queue using the component “Bot: Drupal Rector”.

Comments

Project Update Bot created an issue. See original summary.

project update bot’s picture

Status: Active » Needs review
StatusFileSize
new2.13 KB
Patch for Build #1473

This is an automated patch generated by Drupal Rector. Please see the issue summary for more details.

It is important that any automated tests available are run with this patch and that you manually test this patch.

This patch was created using these packages:

  1. mglaman/phpstan-drupal: 0.12.3
  2. palantirnet/drupal-rector: 0.5.4
  3. rector/rector-prefixed: dev-master

Debug info: Run #1473

project update bot’s picture

Issue summary: View changes
Issue tags: +Drupal 9 compatibility

Fixing summary

edycarreyes99’s picture

Assigned: Unassigned » edycarreyes99
Issue summary: View changes
StatusFileSize
new3.54 KB
new3.54 KB

The previus patch is not working and still has errors on dev branch so I fixed it on the next patch:

Microsoft Translator
Scanned on Tue, 06/30/2020 - 22:50.

4 errors found. 4 warnings found. Avoid some manual work by using drupal-rector
for fixing issues automatically or Upgrade Rector to generate patches.

web/modules/contrib/tmgmt_microsoft/src/Plugin/tmgmt/Translator/MicrosoftTransla
tor.php:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                            │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Fix now  │ 106  │ Call to deprecated method url() of class                     │
│          │      │ Drupal\Core\Entity\EntityInterface. Deprecated in            │
│          │      │ drupal:8.0.0 and is removed from drupal:9.0.0. Please use    │
│          │      │ toUrl() instead.                                             │
│          │      │                                                              │
│ Fix with │ 117  │ Call to deprecated method strlen() of class                  │
│ rector   │      │ Drupal\Component\Utility\Unicode. Deprecated in drupal:8.6.0 │
│          │      │ and is removed from drupal:9.0.0. Use mb_strlen() instead.   │
│          │      │                                                              │
│ Fix with │ 176  │ Call to deprecated function drupal_set_message(). Deprecated │
│ rector   │      │ in drupal:8.5.0 and is removed from drupal:9.0.0. Use        │
│          │      │ Drupal\Core\Messenger\MessengerInterface::addMessage()       │
│          │      │ instead.                                                     │
│          │      │                                                              │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘

web/modules/contrib/tmgmt_microsoft/src/Tests/MicrosoftTest.php:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                            │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Check    │ 15   │ Class Drupal\tmgmt_microsoft\Tests\MicrosoftTest extends     │
│ manually │      │ deprecated class Drupal\tmgmt\Tests\TMGMTTestBase.           │
│          │      │                                                              │
│ Check    │ 35   │ Call to method setUp() of deprecated class                   │
│ manually │      │ Drupal\tmgmt\Tests\TMGMTTestBase.                            │
│          │      │                                                              │
│ Fix with │ 116  │ Call to deprecated function entity_create(). Deprecated in   │
│ rector   │      │ drupal:8.0.0 and is removed from drupal:9.0.0. Use The       │
│          │      │ method overriding Entity::create() for the entity type, e.g. │
│          │      │ \Drupal\node\Entity\Node::create() if the entity type is     │
│          │      │ known. If the entity type is variable, use the entity        │
│          │      │ storage's create() method to construct a new entity:         │
│          │      │                                                              │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘

web/modules/contrib/tmgmt_microsoft/tmgmt_microsoft.info.yml:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                            │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Check    │ 0    │ Add core_version_requirement: ^8 || ^9 to designate that the │
│ manually │      │ module is compatible with Drupal 9. See                      │
│          │      │ https://drupal.org/node/3070687.                             │
│          │      │                                                              │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘

web/modules/contrib/tmgmt_microsoft/tmgmt_microsoft_test/tmgmt_microsoft_test.in
fo.yml:
┌──────────┬──────┬──────────────────────────────────────────────────────────────┐
│  STATUS  │ LINE │                           MESSAGE                            │
├──────────┼──────┼──────────────────────────────────────────────────────────────┤
│ Check    │ 0    │ Add core_version_requirement: ^8 || ^9 to designate that the │
│ manually │      │ module is compatible with Drupal 9. See                      │
│          │      │ https://drupal.org/node/3070687.                             │
│          │      │                                                              │
└──────────┴──────┴──────────────────────────────────────────────────────────────┘
heddn’s picture

Status: Needs review » Needs work
  1. +++ b/src/Plugin/tmgmt/Translator/MicrosoftTranslator.php
    @@ -99,6 +101,7 @@ class MicrosoftTranslator extends TranslatorPluginBase implements ContainerFacto
    +   * @throws EntityMalformedException
    

    This isn't needed.

  2. +++ b/src/Plugin/tmgmt/Translator/MicrosoftTranslator.php
    @@ -155,7 +158,7 @@ class MicrosoftTranslator extends TranslatorPluginBase implements ContainerFacto
    +      MessengerInterface::addMessage($e->getMessage(),
    

    An interface can't have action. This is wrong.

edycarreyes99’s picture

Status: Needs work » Needs review
StatusFileSize
new3.91 KB
new3.91 KB

I fixed the mistakes that I made and applied it on a new patch

heddn’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/tmgmt/Translator/MicrosoftTranslator.php
@@ -40,6 +40,8 @@ use Drupal\tmgmt\Translator\TranslatableResult;
+  use MessengerTrait;

One small thing left. This isn't needed as the parent class already does it.

adityasingh’s picture

Status: Needs work » Needs review
StatusFileSize
new3.64 KB
new458 bytes

Hi @heddn
Updated patch please review.

heddn’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/tmgmt/Translator/MicrosoftTranslator.php
@@ -23,6 +22,7 @@ use GuzzleHttp\Psr7\Request;
+use Drupal\Core\Messenger\MessengerTrait;

Still left the import for the trait. So close.

adityasingh’s picture

Status: Needs work » Needs review
StatusFileSize
new3.36 KB
new491 bytes

Hi @heddn
Made changes as you suggested #9 please have a look.
Thanks

heddn’s picture

Status: Needs review » Needs work
+++ b/src/Tests/MicrosoftTest.php
@@ -5,6 +5,7 @@
+use Drupal;

@@ -124,7 +125,7 @@ class MicrosoftTest extends TMGMTTestBase {
+    $node = Drupal::entityTypeManager()->getStorage('node')->create(array(

Super nit: Sorry I missed this earlier. This import here isn't needed either. Just call it directly \Drupal::entityTypeManager()

adityasingh’s picture

Assigned: edycarreyes99 » adityasingh

I'm working on this.

adityasingh’s picture

Assigned: adityasingh » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.36 KB
new463 bytes

Updated patch please review.

heddn’s picture

Status: Needs review » Needs work
+++ b/src/Tests/MicrosoftTest.php
@@ -5,6 +5,7 @@
+use Drupal;

This leaves the un-needed import.

adityasingh’s picture

StatusFileSize
new3.18 KB
new316 bytes

Remove un-needed import. Please Review.

adityasingh’s picture

Status: Needs work » Needs review
heddn’s picture

Status: Needs review » Reviewed & tested by the community

Looking good now.

heddn’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.21 KB

  • heddn committed 8c02951 on 8.x-1.x
    Issue #3141913 by adityasingh, heddn: Automated Drupal Rector fixes
    
heddn’s picture

StatusFileSize
new6.39 KB

A few more things are needed.

  • heddn committed e554dba on 8.x-1.x
    Issue #3141913 by adityasingh, heddn: Automated Drupal Rector fixes
    
heddn’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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