Fix deprecation notice for Permission::__construct() deprecation error for Drupal 11

Created on 26 February 2025, about 2 months ago

Problem/Motivation

In Drupal 11, php unit tests are generating the following deprecation error. This happens for almost all tests

5 tests triggered 2 deprecations:

1) /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/core/modules/user/src/Plugin/views/access/Permission.php:72
Calling Drupal\user\Plugin\views\access\Permission::__construct() with the $module_extension_list argument as ModuleHandlerInterface is deprecated in drupal:10.3.0 and will be required in drupal:12.0.0. See https://www.drupal.org/node/3310017

Triggered by:

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIp (87 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:68

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpAccessControl (87 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:766

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpBulkDelete (87 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:206

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpBulkDisassociate (87 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:315

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpEdit (87 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:159

2) /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:52
Calling Drupal\user\Plugin\views\access\Permission::__construct() with the $module_extension_list argument as ModuleHandlerInterface is deprecated in drupal:10.3.0 and will be required in drupal:12.0.0. See https://www.drupal.org/node/3310017

Triggered by:

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIp (9 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:68

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpAccessControl (2 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:766

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpBulkDelete (10 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:206

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpBulkDisassociate (10 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:315

* Drupal\Tests\aws_cloud\Functional\Ec2\ElasticIpTest::testElasticIpEdit (4 times)
  /Users/baldwin/Devel/Docomo/distro.drupal.dev/docroot/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/ElasticIpTest.php:159

The error happens because ModuleHandlerInterface $module_handler is used in constructor of ViewsCloudContextAccess.php This should be changed to ModuleExtensionList $module_extension_list

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

8.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States baldwinlouie

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024