Problem/Motivation

Whilst working on a project I want to be able to have tests trigger deprecation errors so that I can confirm that custom code is not using any deprecated core code. However, contrib code is likely to still be using deprecated APIs that trigger silenced deprecations.

Currently in order to do this the project patches the getSkippedDeprecations() in order to run deprecation tests and keep a record of our current technical debt (at this point it is all contribs technical debt).

Giving projects a better way to do this helps them prepare for new major version of Drupal.

Proposed resolution

Allow projects to set an environment variable that points to a file containing a list of addition deprecations to skip.

Projects can define a DRUPAL_DEPRECATION_SKIP_FILE that points to a file. The file contains a JSON encode array of deprecation messages to skip.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

@todo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new2.44 KB

Something like this.

alexpott’s picture

Issue summary: View changes
xjm’s picture

Why can't they just override the method?

larowlan’s picture

WebtestBase is calling that method directly, without using the trait it seems. We'd need to sort that.

But I think that static method overridding in traits is a bit odd see https://3v4l.org/1GFNa

alexpott’s picture

It's not really possible. It's called statically and this method is part of the test infrastructure. It is not part of each test class. Symfony handles this situation a bit more elegantly because they can detect whether it's your deprecation or a vendor deprecation. So you can set SYMFONY_DEPRECATIONS_HELPER to different values to determine with deprecations cause fails. But with Drupal our contrib modules and core are not in vendor so it's more complicated. And also in this case I wouldn't want to ignore new deprecations triggered by core. I'd want to investigate a find out if it was our custom code or contrib that was causing the new deprecation to be triggered.

alexpott’s picture

Also overriding this on a per test basis is not what a project wants to do. A project wants to maintain a list of its technical debt and then it can say to a dev work on removing this deprecation from the list. So having this in a json file on the project level is helpful because all your technical debt is listed in one place.

Thinking about this some more. I'm not sure I like the env var. It's better to check for a dot file in project root. Easy to document and less fragile.

alexpott’s picture

Thinking about this some more. I'm not sure I like the env var. It's better to check for a dot file in project root. Easy to document and less fragile.

Ugh... that's not going to be simple to get Drupal root in there. Env var it is.

alexpott’s picture

StatusFileSize
new2.75 KB

Here's a Drupal 8 version since this patch is more useful there...

alexpott’s picture

StatusFileSize
new1.84 KB
new3.47 KB
new3.17 KB

Still do + when I mean array_merge()... ho hum. Real world testing FTW.

alexpott’s picture

I'm successfully using #10 on a project and now we can maintain a list of skipped deprecations in a file which is much easier to manage than a patch.

heddn’s picture

Version: 8.9.x-dev » 9.2.x-dev
StatusFileSize
new2.93 KB
heddn’s picture

No interdiff as just a re-roll to apply on 9.2.x.

anmolgoyal74’s picture

StatusFileSize
new3.47 KB

Re-Rolled for 8.9.x

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexpott’s picture

StatusFileSize
new2.52 KB

Reroll for 9.3.x / 9.4.x

Status: Needs review » Needs work

The last submitted patch, 16: 3143388-2-16.patch, failed testing. View results

paulocs’s picture

Status: Needs work » Needs review
StatusFileSize
new835 bytes
new3.12 KB

Attaching the correct reroll.

alexpott’s picture

@paulocs++ thanks

alexpott’s picture

StatusFileSize
new3.16 KB

I think the patch in #18 is for 9.4.x only. Here's a 9.3.x patch for those that need it.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

I've been using this patch on several sites long enough, we should just do the right thing. LGTM.

paulocs’s picture

Btw yes, patch #18 is for drupal 9.4.x branch only.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 20: 3143388-9.3.x-20.patch, failed testing. View results

heddn’s picture

Status: Needs work » Reviewed & tested by the community
mondrake’s picture

quietone’s picture

Status: Reviewed & tested by the community » Needs work

This still needs a change record and the 9.3.x patch is being retested which no longer applies.

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new3.03 KB
new2.98 KB
heddn’s picture

Issue tags: -Needs change record

Added a change notice.

edysmp’s picture

Status: Needs review » Reviewed & tested by the community

Works great!

alexpott’s picture

StatusFileSize
new1.21 KB
new3.07 KB
new3.01 KB
new3.3 KB

The test will trigger a PHP 8.1 deprecation and the patch does not apply to 10.0.x.

Patches attached fix all of this.

The last submitted patch, 31: 3143388-9.3.x-31.patch, failed testing. View results

The last submitted patch, 31: 3143388-9.3.x-31.patch, failed testing. View results

The last submitted patch, 31: 3143388-9.3.x-31.patch, failed testing. View results

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexpott’s picture

StatusFileSize
new3.05 KB
new3.3 KB

Rerolled for 9.4.x

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 37: 3143388-10.0.x-37.patch, failed testing. View results

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

heddn’s picture

Version: 10.1.x-dev » 9.5.x-dev
Category: Bug report » Feature request
StatusFileSize
new3.1 KB

Reroll for 9.5

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.