Line   src/Form/DeleteMultiple.php
 ------ --------------------------------------------------------------------------------------------------
  47     Parameter $manager of method Drupal\message\Form\DeleteMultiple::__construct() has typehint with
         deprecated interface Drupal\Core\Entity\EntityManagerInterface:
         in drupal:8.0.0 and is removed from drupal:9.0.0.
 ------ --------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------
  Line   src/Form/MessageSettingsForm.php
 ------ ---------------------------------------------------------------------------------------------------------
  78     Parameter $entity_manager of method Drupal\message\Form\MessageSettingsForm::__construct() has typehint
         with deprecated interface Drupal\Core\Entity\EntityManagerInterface:
         in drupal:8.0.0 and is removed from drupal:9.0.0.
 ------ ---------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------
  Line   tests/src/Functional/MessageCron.php
 ------ ------------------------------------------------------------------------------------------------------------
  102    Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use
         \Drupal::time()->getRequestTime();
  109    Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use
         \Drupal::time()->getRequestTime();
  116    Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use
         \Drupal::time()->getRequestTime();
 ------ ------------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------
  Line   tests/src/Kernel/Plugin/MessagePurge/DaysTest.php
 ------ ------------------------------------------------------------------------------------------------------------
  82     Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use
         \Drupal::time()->getRequestTime();
  99     Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use
         \Drupal::time()->getRequestTime();
 ------ ------------------------------------------------------------------------------------------------------------


 [ERROR] Found 7 errors

Comments

kbrodej created an issue. See original summary.

swatichouhan012’s picture

Assigned: Unassigned » swatichouhan012
Status: Active » Needs work
Issue tags: +vb13febContribution

We will work on #vb13febContribution.

swatichouhan012’s picture

Assigned: swatichouhan012 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.04 KB

Kindly review patch to fix deprecated code issue.

kbrodej’s picture

StatusFileSize
new26.7 KB
new23.23 KB

Hi. Was working on patch, when I saw you already posted yours. I reviewed it and made some changes in the attached patch. Running the tests reported several deprecation messages which are fixed as well.

Even though report says

  Line   tests/src/Kernel/Plugin/MessagePurge/DaysTest.php
 ------ ------------------------------------------------------------------------------------------------------------
  82     Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use

we should use dependency injection.

pfrenssen’s picture

Status: Needs review » Needs work
  1. diff --git a/src/Form/DeleteMultiple.php b/src/Form/DeleteMultiple.php
    index e40c97a..56dee20 100644
    --- a/src/Form/DeleteMultiple.php
    +++ b/src/Form/DeleteMultiple.php
    @@ -41,10 +41,11 @@ class DeleteMultiple extends ConfirmFormBase {
        *
        * @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
        *   The tempstore factory.
    -   * @param \Drupal\Core\Entity\EntityManagerInterface $manager
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $manager
        *   The entity manager.
        */
    

    Let's also update the documentation to say "The entity type manager".

  2. diff --git a/src/Form/DeleteMultiple.php b/src/Form/DeleteMultiple.php
    index e40c97a..56dee20 100644
    --- a/src/Form/DeleteMultiple.php
    +++ b/src/Form/DeleteMultiple.php
    @@ -41,10 +41,11 @@ class DeleteMultiple extends ConfirmFormBase {
    -  public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityManagerInterface $manager) {
    +  public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityTypeManagerInterface
    +   $manager) {
    

    This is introducing a newline, let's keep it all on one line like it was before.

  3. diff --git a/src/Form/MessageSettingsForm.php b/src/Form/MessageSettingsForm.php
    index 4b5deb8..7077ac7 100644
    --- a/src/Form/MessageSettingsForm.php
    +++ b/src/Form/MessageSettingsForm.php
    @@ -18,11 +18,11 @@ class MessageSettingsForm extends ConfigFormBase {
       /**
        * The entity manager object.
        *
    -   * @var \Drupal\Core\Entity\EntityManagerInterface
    +   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
        *
        * @todo Use the entity type manager service.
        */
    

    This @todo can now also be removed.

  4. diff --git a/src/Form/MessageSettingsForm.php b/src/Form/MessageSettingsForm.php
    index 4b5deb8..7077ac7 100644
    --- a/src/Form/MessageSettingsForm.php
    +++ b/src/Form/MessageSettingsForm.php
    @@ -70,14 +70,14 @@ class MessageSettingsForm extends ConfigFormBase {
        *
        * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
        *   The factory for configuration objects.
    -   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
    +   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
        *   The entity manager object.
    

    Let's update the documentation to The entity type manager.

  5. @@ -99,21 +109,22 @@ class MessageCron extends MessageTestBase {
         // Create messages.
         for ($i = 0; $i < 4; $i++) {
           Message::Create(['template' => 'template1'])
    -        ->setCreatedTime(REQUEST_TIME - 3 * 86400)
    +
    +        ->setCreatedTime($this->timeService->getRequestTime() - 3 * 86400)
             ->setOwnerId($this->account->id())
             ->save();
         }
    

    Let's not introduce a newline in the middle of a chained method call.

swatichouhan012’s picture

Status: Needs work » Needs review
StatusFileSize
new26.85 KB
new2.02 KB

I have updated patch wrt comment #5, kindly review new patch

dunebl’s picture

#6 looks good to me...

rokzabukovec’s picture

Status: Needs review » Reviewed & tested by the community

Hi.
I ran the drupal-check command and the patch from #6 clears all the deprecation errors. So I'm marking this as RTBC.
Best regards

ravimane23’s picture

StatusFileSize
new27.64 KB
new839 bytes

applied #6 cleanly, and installed it on both D8 and D9. works fine!

In addition to patch #6, I have added changes in .info.yml file.

Please review the patch.

 drupal-check -d message
 55/55 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 [OK] No errors                                                                 
ravimane23’s picture

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

Version: 8.x-1.x-dev » 7.x-1.6
StatusFileSize
new26.4 KB
new28.14 KB

Hi i have found some code comment issue apart from this All looks good. that has been fixed in #11
Please review this patch.

pavnish’s picture

Version: 7.x-1.6 » 8.x-1.x-dev
meet_bhanvadia’s picture

Status: Needs review » Reviewed & tested by the community

Hi all, Successfully applied the patch #11.

heddn’s picture

Status: Reviewed & tested by the community » Needs work

So, the changes here work. However, they introduce some things that aren't strictly D9 compatibility issues and raise questions. Better to move them to a follow-up issue external to D9 compatibility.

  1. +++ b/tests/src/Functional/MenuTest.php
    @@ -2,6 +2,7 @@
    +use Drupal\Core\StringTranslation\StringTranslationTrait;
    
    @@ -11,6 +12,7 @@ use Drupal\Tests\BrowserTestBase;
    +  use StringTranslationTrait;
    
    @@ -26,13 +35,13 @@ class MenuTest extends BrowserTestBase {
    +    $this->assertSession()->linkExists($this->t('Message'));
    ...
    +    $this->assertSession()->linkExists($this->t('Message'));
    ...
    +    $this->clickLink($this->t('Message'));
    
    +++ b/tests/src/Functional/MessageCron.php
    @@ -2,6 +2,7 @@
    +use Drupal\Core\StringTranslation\StringTranslationTrait;
    
    @@ -11,6 +12,7 @@ use Drupal\message\Entity\MessageTemplate;
    +  use StringTranslationTrait;
    
    @@ -67,7 +77,7 @@ class MessageCron extends MessageTestBase {
    +    $this->assertEqual($message_template->getSetting('purge_methods'), $settings['purge_methods'], $this->t('Purge settings are stored in message template.'));
    

    These changes here and elsewhere are not needed for D9 support. Let's remove those. They just make the patch hard to review. And bring up concerns with even using t() at all. Typically tests are written without them and we can assume all strings are in English.

  2. +++ b/tests/src/Functional/MessageCron.php
    @@ -176,8 +186,8 @@ class MessageCron extends MessageTestBase {
    -    $this->assertEqual(count(Message::queryByTemplate('template2')), 2, t('Template2 messages were not deleted due to settings override.'));
    +    $this->assertEqual(count(Message::queryByTemplate('template1')), 0, $this->t('All template1 messages deleted.'));
    +    $this->assertEqual(count(Message::queryByTemplate('template2')), 2, $this->t('Template2 messages were not deleted due to settings override.'));
    
    +++ b/tests/src/Functional/MessageEntityDelete.php
    @@ -182,10 +182,10 @@ class MessageEntityDelete extends MessageTestBase {
    -    $this->assertTrue(Message::load($message->id()), 'Message exists after deleting one of two referenced nodes.');
    +    $this->assertNotEmpty(Message::load($message->id()), 'Message exists after deleting one of two referenced nodes.');
    ...
    -    $this->assertFalse(Message::load($message->id()), 'Message deleted after deleting all referenced nodes.');
    +    $this->assertEmpty(Message::load($message->id()), 'Message deleted after deleting all referenced nodes.');
    

    Are these needed for phpunit compatibility? I can't see they are strictly needed to support D9 either.

  3. +++ b/tests/src/Unit/Plugin/MessagePurge/DaysTest.php
    @@ -27,6 +27,7 @@ class DaysTest extends UnitTestCase {
    +    /** @var \Drupal\Core\Queue\QueueInterface $queue */
    
    @@ -41,6 +42,7 @@ class DaysTest extends UnitTestCase {
    +    /** @var \Drupal\Core\Queue\QueueInterface $queue */
    

    These aren't needed.

pavnish’s picture

Status: Needs work » Needs review
StatusFileSize
new16.26 KB
new11.22 KB

@heddn Hi ,
Thanks for the your suggestion you are absolutely correct.
I have removed unnecessary changes from #11.Could you please review this.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

  • jhedstrom committed 98ac892 on 8.x-1.x authored by pavnish
    Issue #3113123 by pavnish, swatichouhan012, kbrodej, ravimane23: Drupal...
jhedstrom’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all!

Status: Fixed » Closed (fixed)

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