Since 10th November 2017 automated daily testing for Scheduler at core 8.5 fails with a deprecation message:

\Drupal\Core\Routing\Enhancer\RouteEnhancerInterface is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, you should use \Drupal\Core\Routing\EnhancerInterface. See https://www.drupal.org/node/2894934
See https://www.drupal.org/pift-ci-job/807329

The failures are all within Schedulers 'Rules Integration' tests and the deprecated code is actually in the Rules module.

Interestingly, the message says "deprecated in Drupal 8.4.0" but it is actually 8.5 in which the message and test failure occurs - it runs OK at 8.4. This has now ben fixed in #2926412: Follow-up for #2883680: deprecation message indicates the wrong deprecation introduction version


Note: This issue was originally raised in the Scheduler issue queue, but was moved to Rules in comment #3

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

jonathan1055’s picture

Project: Scheduler » Rules
Version: 8.x-1.x-dev » 8.x-3.x-dev
Component: Code » Rules Core
Category: Task » Bug report
Issue summary: View changes
Related issues: +#2883680: Force all route filters and route enhancers to be non-lazy, +#2870194: Ensure that process-isolated tests can use Symfony's PHPunit bridge to catch usages of deprecated code

The tests which fail are actually all in the Rules integration:

    35x in SchedulerRulesEventsTest::testRulesEvents
    14x in SchedulerRulesConditionsTest::testNodeIsScheduledConditions
    14x in SchedulerRulesActionsTest::testUnpublishOnActions
    14x in SchedulerRulesActionsTest::testPublishOnActions
    5x in SchedulerRulesConditionsTest::testNodeTypeEnabledConditions

It is not a fault in the Scheduler code. but in Rules src/Routing/RulesUiRouteEnhancer.php which uses the deprecated code.

Moving this issue to the Rules queue where I will work on a fix - and to add a test so that Rules itself will find the fault in its own code ;-)

jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new466 bytes

In my Travis build, the Rules code does fail at 8.5 which is good. It is just that we have not seen any Rules patches tested at 8.5 since the commit of #2870194: Ensure that process-isolated tests can use Symfony's PHPunit bridge to catch usages of deprecated code on 9th November. Daily Rules testing is only at 8.4 currently.

To check this, here is a dummy patch which alters no code. It should fail tests at 8.5 but run OK at 8.4

jonathan1055’s picture

As expected the current code fails at 8.5 but passes at 8.4

Here is the fix to use the new EnhancerInterface class. I am expecting this patch to pass at 8.5 but fail at 8.4

jonathan1055’s picture

As expected, when fixing the tests to pass at 8.5 they fail at 8.4 and 8.3

When #2923267: Allow test classes to specify skipped deprecations too lands, we will be able to leave the existing deprecated code in place, add a @todo referencing this issue and list the deprecation message to be skipped in the 20 test classes that fail.

An alternative would be to try to create a \Drupal\Core\Routing\EnhancerInterface class in 8.4 and 8.3 which would use the new class but allow the same interface. Then code could be fixed and we would not have to carry forward 'technical debt' to fix in the future.

jonathan1055’s picture

The core patch for 8.4 and 8.3 is simple and allows the fixed Rules code to pass at 8.5, 8.4 and 8.3. I have posted a patch on #2883680-112: Force all route filters and route enhancers to be non-lazy but that issue is closed so I am not certain how much visibility it will get.

tr’s picture

Priority: Normal » Major

This not only affects Rules, but affects all modules which have a dependency on Rules. Most of my tests now fail because of this, even though those tests don't involve Rules - if you a have the dependency on Rules in your .info.yml the tests fail.

Bumping to Major because of this.

jonathan1055’s picture

Given that the new classes have not been committed to core 8.4 and 8.3 (and there is no movement or response to my patch in #112 of #2883680-112: Force all route filters and route enhancers to be non-lazy in the meantime we should be able to make the Rules tests pass by adding @group legacy to the tests. I will make a patch for this and see how it goes.

jonathan1055’s picture

StatusFileSize
new11.35 KB

Here's a patch which add @group legacy to 16 kernel test files and 4 functional test files. Each file has:

 * @group legacy
 * @todo Remove the 'legacy' tag when Rules no longer uses deprecated code.
 * @see https://www.drupal.org/project/rules/issues/2922757

This should allow the tests to pass at core 8.5, 8.4 and 8.3

jonathan1055’s picture

Good, as expected Rules tests pass at 8.5, 8.4 and 8.3 with this patch. Travis build results are https://travis-ci.org/jonathan1055/rules/builds/304651753 and I will create a pull-request

I've raised #2924899: Backport \Routing\EnhancerInterface to core 8.4 to discuss the problem of how Rules can remove the deprecated code without creating a new code branch and separating 8.5 development from 8.4/8.3 (which is too big a burden just to get tests to pass)

tr’s picture

Priority: Major » Critical
Status: Needs review » Reviewed & tested by the community

I have applied the patch and tested it locally, and it works to eliminate the deprecated failures in PHPUnit tests, both for the Rules codebase and for my own code which depends on Rules. Thanks you.

Critical, because this problem causes testing failures for ALL projects which depend upon Rules. Flag is the latest victim - just declaring a test_dependency on Rules in flag.info.yml has caused Flag branch testing to start failing with Drupal 8.5.x. Flag has almost as many D8 users as Rules does ...

I realize this is a problem caused entirely by Core declaring that newly @deprecated functions should immediately cause test failures for contrib, but as it has brought to a screeching halt all development in the Rules ecosystem, it's something we have to deal with now - it can't be postponed until Core changes its policy.

Curiously, Core is excluded from generating these failures on its own code, so while Core is riddled with @deprecated usage it manages to avoid all consequences of this ill-considered decision.

jonathan1055’s picture

Thanks for testing TR. I will make a Pull Request for the change later today. Hopefully @fago will be able to commit this soon, but I know he does not have much time to spend on Rules.

There is some good discussion from #56 on #2607260-56: [meta] Core deprecation message introduction, contrib testing etc. where deprecation failures should be shown as a artifact of the test results and not make them fail. I think that solution is ideal.

jonathan1055’s picture

I have created a PR for this change: https://github.com/fago/rules/pull/497

jonathan1055’s picture

Note, the patch in #10 and PR 497 are only the first step to fixing this. When committed (hopefully soon), the issue should remain open (and postponed) until 8.5 is released and 8.6.x-dev is available. Then we no longer need to test against 8.4 and can replace the deprecated code by using the patch in #5.

  • fago committed e51f60e on 8.x-3.x authored by jonathan1055
    Issue #2922757 by jonathan1055, TR: Replace deprecated...
fago’s picture

Status: Reviewed & tested by the community » Needs work

Thanks, I committed the patch from #10. Let's set this to needs work then, so we can address the legacy issues.

fago’s picture

So we need to go through the 8.5 fails and fix the deprecation warnings there.

fago’s picture

https://travis-ci.org/fago/rules works thanks to the legacy tag, when we remove those the deprecation warnings come up again.

jonathan1055’s picture

Issue summary: View changes
Status: Needs work » Postponed

In #18 fago said:

So we need to go through the 8.5 fails and fix the deprecation warnings there.

My patch in #5 does this, and fixes the rules code, but it can only be committed for 8.5+
Our tests should be run at development (8.6) pre-release (8.5) and stable (8.4) so at the moment we cannot fix the Rules code because the new EnhancerInterface is not available in core 8.4. We have to support the current stable release which is 8.4

Setting this to postponed, and when the stable release is 8.5 and we no longer need to support 8.4 we use the patch in #5 and also revert the @group legacy changes from patch #10/commit #16.

Hope that's OK with you?

Jonathan

idebr’s picture

Status: Postponed » Needs review

8.5 is the current stable version, so this issue is no longer postponed.

The patch in this issue should also remove the @group legacy annotation from the tests that was added before.

tr’s picture

@idebr: Can you supply a new patch?

jonathan1055’s picture

Issue summary: View changes
StatusFileSize
new1.52 KB

Just for interest here is the same patch as from #5. I don't have the means at the moment to test this locally so it might not even apply any more.

Status: Needs review » Needs work

The last submitted patch, 23: 2922757-23.replace-RouteEnhancerInterface.patch, failed testing. View results

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new11.35 KB

Apparently the changes proposed in #5 (and #23) have already been committed as part of #2951263: With Rules enabled, page_manager pages return a 404 after core 8.5 update.

So I believe the only thing left, now that 8.5 is the 'stable' release, is to remove the @group legacy annotation. Patch attached.

jonathan1055’s picture

Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community
Related issues: +#2951263: With Rules enabled, page_manager pages return a 404 after core 8.5 update

Thanks for spotting that. Yes, the commit is https://cgit.drupalcode.org/rules/commit/?id=d67f785 which does pretty much the same as patch #5

Setting back to 'normal' now that this is only removing the @group legacy code. RTBC I think?

jonathan1055’s picture

Status: Reviewed & tested by the community » Needs work

The tests at D8.5.5 were green, but they are not showing now. Sorry I changed to RTBC too early.

jonathan1055’s picture

The test fails are unrelated. Pass at 8.5 but fail at 8.6 and 8.7. We've had 2 test fails daily from 21 March 2018 up to 13 July. Then we've had 8 test fails daily since then. I cannot see any issue raised yet to deal with these test failures.

jonathan1055’s picture

Raised #2989050: 'No reaction rule' message uses singular form in 8.5 but plural form in 8.6 for the test failures. I don't currently have the means to test code locally (unfortunately) so I can't investigate these errors and provide patches. But at least the issue exists now.

jonathan1055’s picture

Title: Replace deprecated RouteEnhancerInterface » Replace deprecated RouteEnhancerInterface, then remove @group legacy
Status: Needs review » Reviewed & tested by the community
Related issues: +#2989417: Argument 1 passed to \EntityContext::fromEntity() must implement EntityInterface

Also added #2989417: Argument 1 passed to \EntityContext::fromEntity() must implement EntityInterface for the other test failures.

Removing the @group legacy is RTBC as the failures above are unrelated. Thanks TR.

  • TR committed b40ade2 on 8.x-3.x
    Issue #2922757 by jonathan1055, TR, fago: Replace deprecated...
tr’s picture

Status: Reviewed & tested by the community » Fixed

Committed #25.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kristen pol’s picture

Issue tags: +Drupal 9 compatibility

Per a Slack discussion with Gábor Hojtsy regarding usage of D9 tags (Drupal 9, Drupal 9 compatibility, Drupal 9 readiness, etc.), "Drupal 9 compatibility" should be used for contributed projects that need updating and "Drupal 9" was the old tag for D8 issues before the D9 branch was ready. Doing tag cleanup here based on that discussion.

tr’s picture

Issue tags: -Drupal 9 compatibility
jonathan1055’s picture

Adding to parent