Allow deprecation testing to distinguish between major versions when contrib modules run tests

Created on 28 July 2021, about 3 years ago
Updated 13 June 2024, 3 months ago

Problem/Motivation

During the development of Drupal 9, we postponed any issue that would add a new deprecation after 8.8.0 (i.e., anything being deprecated for removal in 10.0.x) in order to ensure site and module owners would not be continuously told to change additional things that were not required for their site to be ready for Drupal 9.

However, with the shorter Drupal 9 lifetime and cramped Drupal 10 development cycle, it would be better to allow deprecations to be committed when they are ready, rather than postponing issues for 6-12 months. This would also ensure that any 9.4 deprecations for 10.0 do get immediate attention. (For example, we might allow certain modules or themes to be deprecated and moved to contrib after 9.3.0-beta1, e.g. if the CKEditor 5 module is not stable in time for CKEditor 4 to be fully deprecated.)

Upgrade Status and drupal-rector already distinguish between major versions, so we just need to make core/DrupalCI testing do so as well.

Proposed resolution

The simplest way to keep tests from failing on deprecations that "will be removed before drupal:10.0.0" from deprecations that "will be removed before drupal:11.0.0" would be to add the 11.0.0 deprecations to the skipped deprecation list in DeprecationListenerTrait:getSkippedDeprecations() in 9.4 as they are added to core. However, that adds a lot of manual overhead and maintenance.

A better method might be to add a regex that checks which major version the deprecation is for, and automatically skip it if the major version is more than the current major version plus one. (See logic in DeprecationListenerTrait::isDeprecationSkipped() for some existing dynamic regex skips.) Ideally we would add a method to do this, possibly along with a configuration option to allow a project to opt into warnings for all deprecations, or only those affecting the next major version.

Remaining tasks

Decide on approach.

User interface changes

N/A

API changes

TBD

Data model changes

N/A

Release notes snippet

TBD

📌 Task
Status

Active

Version

11.0 🔥

Component
PHPUnit 

Last updated about 11 hours ago

Created by

🇺🇸United States xjm

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • 🇧🇪Belgium Wim Leers Ghent 🇧🇪🇪🇺
  • 🇬🇧United Kingdom catch

    We could consider switching any deprecations that we're leaving in from @trigger_error() to trigger_error() (unsilenced) when we open the new branch.

    From experience, this would have helped with entity query ::accessCheck() where neither phpstan nor test coverage has caught everything and some contrib modules have released Drupal 10 'compatible' versions with exceptions due to that change. If we'd gone from @trigger_error() to an unsilenced deprecation instead of straight to a warning we might have caught more of these before the exception started getting thrown.

  • 🇬🇧United Kingdom catch

    This came up again in 📌 Remove deprecation about Views argument config conversion from numeric to entity_target_id from 10.3.x Closed: duplicate , we might have more options now we're on gitlab. It's also going to become more important with longer major branch lifetimes.

    Re-titling because this is really about contrib testing being able to ignore deprecations that are removed in much later versions.

    For core, we want all deprecations to trigger errors all the time, so that we don't deprecate something we can't remove yet, except for very rare cases (a class implementing a deprecated interface for bc or similar) which we would skip individually.

    For contrib, the default case is usually going to be that until 11.0.0 is released, you want to ignore deprecations for removal in 12.0.0 - especially when the replacement is not in all supported branches back to 10.1 or 10.2.

    But then, at some point after 11.0.0 is released and 10.1/10.2 are out of support, you would want to get notified about deprecations for removal in 12.0.0, and not get notified about deprecations for removal in 13.0.0.

Production build 0.71.5 2024