Problem/Motivation

Contrib tests need to add to \Drupal\Tests\Listeners\DeprecationListener::getSkippedDeprecations() because we're hitting a problem where contrib can't get passing tests on the current stable branch and the dev branch because of deprecations.

Proposed resolution

Pass test class to \Drupal\Tests\Listeners\DeprecationListener::getSkippedDeprecations() and use a static property on the class to get skipped deprecations.

Alternative solution

See comment #30 for an alternative solution that Contrib can use.

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new8.28 KB

Here's a patch that allows tests to add to the skipped deprecations list - this should allow contrib to manage their own approach to tech debt.

jonathan1055’s picture

This looks very interesting, and would solve the problem for Scheduler module https://www.drupal.org/pift-ci-job/810669, until such time as Rules #2922757: Replace deprecated RouteEnhancerInterface, then remove @group legacy is fixed.

Is there a way that a contrib module can test these changes alongside a patch/change for it's own tests? I know you have added tests for the new functionality but it would be good to see how it works for real. If I submit a patch for a contrib module I can't see how I can include this core change in the same test build run. Any ideas?

Thanks for doing this - and making the patch so quickly,

Jonathan

lendude’s picture

  1. +++ b/core/modules/simpletest/src/WebTestBase.php
    @@ -206,6 +206,23 @@
    +   * particular test. Note, that this is means there is technical debt that
    
    +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
    @@ -221,6 +221,22 @@
    +   * particular test. Note, that this is means there is technical debt that
    
    +++ b/core/tests/Drupal/Tests/BrowserTestBase.php
    @@ -274,6 +274,22 @@
    +   * particular test. Note, that this is means there is technical debt that
    

    Should be 'that this means', one 'is' too many

  2. +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListener.php
    @@ -35,13 +35,20 @@ public function endTest(\PHPUnit_Framework_Test $test, $time) {
    +    if (isset($test_class::$skippedDeprecations) && is_array($test_class::$skippedDeprecations)) {
    +      $skipped_deprecations = $test_class::$skippedDeprecations;
    +    }
    

    Do we want to use the same pattern we use for $modules? So check all parent classes, so you can set this in a base class and you don't have to copy it in every child class if the base class runs into deprecations during setup or something?

jonathan1055’s picture

so you can set this in a base class and you don't have to copy it in every child class

@Lendude, that would be really helpful, because the Rules test failures are over 20 test classes.

mile23’s picture

alexpott’s picture

StatusFileSize
new5.67 KB
new9.58 KB

Here's a patch that addresses #4.

I'm not wild about doing this. Something just feels like we're doing this wrong. In the rules case even though their tests are failing on 8.5.x - they are not "really" failing. They are just using deprecated code. In order to not use deprecated code the rules maintainer is going to need to release a new version that only supports 8.5.x and up. So that means a new minor that should only be tested on those versions of Drupal. I think we really need is the ability for contrib to disable/enable deprecation testing on specific branches.

jonathan1055’s picture

@alexpott

I think we really need is the ability for contrib to disable/enable deprecation testing on specific branches.

Not sure this is good, or maybe I have mis-understood. Take the Rules case as an example - to keep the tests passing we turn off deprecation failures when testing at core 8.5.x. Then we would miss new deprecations. Or are you still proposing to have the functionality to select which deprecations to ignore?

I am also not that keen on this solution, as I always want to fix problems asap and not maintain 'tech debt' carried forward. What we really want is backwards compatibility to 8.4 and in this Rules case it is simple to do - I have created a patch on #2883680-112: Force all route filters and route enhancers to be non-lazy which allows the new replacement class to be used in 8.4 and 8.3. Hopefully someone can review it, then commit and we can move forward with replacing the actual deprecated code.

Jonathan

alexpott’s picture

@jonathan1055 well you need to ability to turn off deprecation checking for the current stable branch cause that works on 8.4.x and 8.5.x and then open a new branch which is only compatible with 8.5.x and up that has deprecation checking.

almaudoh’s picture

then open a new branch which is only compatible with 8.5.x and up that has deprecation checking

@alexpott, I don't know if it is worth opening up a new branch each time an API gets deprecated, especially considering that most contrib modules are not yet using semantic versioning. So one would have to jump from 8.x-1.x to 8.x-2.x in order to avoid test fails.

IMHO, a better way would be to require that where API's are deprecated, the new API should be backported to ensure contrib modules can switch to the new API. If we don't want to backport, then the deprecation should be postponed till the next minor Drupal release.

alexpott’s picture

@almaudoh the problem is we are not in charge of all deprecations - lots of the deprecations come Symfony.

jonathan1055’s picture

we are not in charge of all deprecations

That is true, but many of them can be backported easily. The deprecation which caused this entire issue to be started is very easy to backport to 8.4 and 8.3, as per my patch in #2883680-112: Force all route filters and route enhancers to be non-lazy Is it possible for a Core maintainer to take a look at that, because committing this to 8.4 and 8.3 will solve the problem and we can all then move to the new non-deprecated code.

mile23’s picture

@alexpott, I don't know if it is worth opening up a new branch each time an API gets deprecated, especially considering that most contrib modules are not yet using semantic versioning.

Hey, check out this postponed issue: #1612910: [policy, no patch] Switch to Semantic Versioning for Drupal contrib extensions (modules, themes, etc)

:-)

Anyway... If contrib can specify minor versions for compatibility, then making a new release per core minor version is reasonable. But: #2313917: Core version key in module's .info.yml doesn't respect core semantic versioning

You can specify a core branch per contrib branch in the automated testing page of a project. So an 8.x-5.x branch could map to core 8.5.x and test against it.

Also, in an ideal world, we'd be able to specify our own rules about whether deprecations fail the test in our own per-project drupalCI build file: #2901677: Allow projects to contain their own drupalci.yml file

So a lot of work is exposed by this issue, and we could either do it or just allow people to ignore deprecations in an array.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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.

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.

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.

smustgrave’s picture

Should this be targeted for D10?

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.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

This issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200

Moving to PNMI to see if this is still needed? Seems like there was an issue when upgrading from 8.4 from 8.3 that I assume has been resolved as I have not heard of test issues for D10?

And it seems like this wasn't a fix a lot of people here were sure about? But could be mistaken on that.

Version: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Just following up if still valid? If no follow up could close in 3 months

smustgrave’s picture

Wanted to bump 1 more time before closing.

jonathan1055’s picture

It would have been useful, but I guess if it didn't happen back then, it won't be done now. There was also not a clear agreement.
We do still have this type of problem in Contrib at 11.2 - see the list of 3rd-party modules in the summary of #3514380: Autoloading hooks in the file tokens.inc is deprecated D11.2 which clouds the log with noise and affects the test results.
But thanks for following up, though. If no one else picks this up it can be closed.

mondrake’s picture

Well I guess since the introduction of the .deprecation-ignore.txt file this is solved in the sense that contrib can define their own file, and use it during testing with a proper setup of the SYMFONY_DEPRECATIONS_HELPER environment variable, no?

https://git.drupalcode.org/project/drupal/-/blob/11.x/core/phpunit.xml.d...

jonathan1055’s picture

Issue summary: View changes

Thanks mondrake, yes you are right. I had forgotten that solution, and have updated the issue summary. This can be closed now.

mondrake’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Per #31

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.