Deprecate calling Drupal\block\Plugin\migrate\process\BlockTheme::_construct() with the $migration argument

Created on 22 November 2022, over 1 year ago
Updated 22 February 2023, over 1 year ago

Problem/Motivation

In #3319582: Fix calls to methods with too many parameters passed in we discovered the $migration argument in the constructor of Drupal\block\Plugin\migrate\process\BlockTheme is unused.

Let's deprecate it in 10.1 and remove it in 11.0.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.1

Component
Base 

Last updated about 2 hours ago

Created by

🇳🇱Netherlands Spokje

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    Reviewing the MR

    All the threads appear to be address. The one open one appears to be a comment

    Ran just the tests locally and did get a failure

    Failed asserting that string matches format description.
    --- Expected
    +++ Actual
    @@ @@
     @expectedDeprecation:
    -%A  Calling Drupal\block\Plugin\migrate\process\BlockTheme::__construct() with the $migration argument is deprecated in drupal:10.1.0 and is removed in drupal:11.0.0. See https://www.drupal.org/node/3323212
    -  Method "Behat\Mink\Element\ElementInterface::waitFor()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Drupal\Tests\DocumentElement" now to avoid errors or add an explicit @return annotation to suppress this message.
    +  Method "Behat\Mink\Element\ElementInterface::getText()" might add "string" as a native return type declaration in the future. Do the same in implementation "Drupal\Tests\DocumentElement" now to avoid errors or add an explicit @return annotation to suppress this message.
    +  Method "Behat\Mink\Element\ElementInterface::waitFor()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Drupal\Tests\DocumentElement" now to avoid errors or add an explicit @return annotation to suppress this message.
    +  Method "Behat\Mink\Element\ElementInterface::getText()" might add "string" as a native return type declaration in the future. Do the same in implementation "Drupal\Tests\DocumentElement" now to avoid errors or add an explicit @return annotation to suppress this message.
    +  Method "Behat\Mink\Element\ElementInterface::waitFor()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Drupal\Tests\DocumentElement" now to avoid errors or add an explicit @return annotation to suppress this message.
    +  The "PHPUnit\Framework\TestCase::addWarning()" method is considered internal This method is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not extend it from "Drupal\KernelTests\KernelTestBase".
    +  The "Drupal\Tests\Listeners\DrupalListener" class implements "PHPUnit\Framework\TestListener" that is deprecated.
    +  The "Drupal\Tests\Listeners\DrupalListener" class uses "PHPUnit\Framework\TestListenerDefaultImplementation" that is deprecated The `TestListener` interface is deprecated.
    

    Deprecation call is correct version
    All appears good to me

    Good work!

  • Status changed to Needs work over 1 year ago
  • 🇳🇿New Zealand quietone New Zealand

    FYI, the policy for constructor parameter removal has been updated during the life of this issue.

    Setting to NW for the questions raised in the MR.

  • Assigned to mondrake
  • 🇮🇹Italy mondrake 🇮🇹

    Working on this.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇹Italy mondrake 🇮🇹

    I think the questions in the MR are superceded by latest changes.

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    From what I can tell the open threads have been addressed.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States xjm

    alexpott credited xjm .

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    There's no need for the test to be a kernel test - it can be a unit test. Doing the following fixes this...

    diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockThemeDeprecationTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockThemeDeprecationTest.php
    index 327743f2ae..05eddff578 100644
    --- a/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockThemeDeprecationTest.php
    +++ b/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockThemeDeprecationTest.php
    @@ -1,11 +1,11 @@
     <?php
     
    -namespace Drupal\Tests\block\Kernel\Plugin\migrate\process;
    +namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
     
     use Drupal\block\Plugin\migrate\process\BlockTheme;
     use Drupal\Core\Config\Config;
    -use Drupal\KernelTests\KernelTestBase;
     use Drupal\migrate\Plugin\MigrationInterface;
    +use Drupal\Tests\UnitTestCase;
     
     /**
      * Tests the deprecation notices of the block theme.
    @@ -14,7 +14,7 @@
      *
      * @group block
      */
    -class BlockThemeDeprecationTest extends KernelTestBase {
    +class BlockThemeDeprecationTest extends UnitTestCase {
     
       /**
        * Tests the deprecation in the constructor.
    

    But actually I think there are some further things to do...

        assert($theme_config instanceof Config);
        assert(is_array($themes));
    

    isn't the invalid arguments I asked for originally... but we have property types... and in this class we have...

      /**
       * Contains the system.theme configuration object.
       *
       * @var \Drupal\Core\Config\Config
       */
      protected $themeConfig;
    
      /**
       * List of themes available on the destination.
       */
      protected array $themes;
    

    So the assert(is_array($themes)); is pointless and I would argue that we should take this opportunity to add the property typehint to protected $themeConfig; and whilst we're here we should remove protected $configFactory; because it is never set.

  • Status changed to Needs review over 1 year ago
  • 🇮🇹Italy mondrake 🇮🇹

    done #25 (dunno why the MR pushes are now displaced vs d.org comments), then some:

    1) removed @coversDefaultClass from test since it is only testing deprecation, and we saw it is confusing if left in (see 📌 Add phpstan/phpstan-phpunit as a dev dependency Fixed ).
    2) made the array declaration a bit more stringent string[].

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Change looks fine to me but been wrong twice before

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed f979f42 and pushed to 10.1.x. Thanks!

  • Status changed to Fixed over 1 year ago
    • alexpott committed f979f42e on 10.1.x
      Issue #3323209 by Spokje, mondrake, smustgrave, alexpott, xjm: Deprecate...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024