Problem/Motivation

Scheduler issue #3035104: [meta] Remove deprecated code flagged by @trigger_error messages for Drupal 9 compatibility detects all occurrences of deprecated code that throw @trigger_error warnings when used. However, there are a number of deprecated methods and classes in core that do not yet trigger an error when used. Many of these originated prior to 8.4 when there was no coherent deprecation policy. Matt Glaman has developed drupal-check which performs a static analysis and detects deprecated code usage through the @deprecated tags and provides a more thorough report.

For more information, including how to produce the report, see https://github.com/mglaman/drupal-check/wiki/Drupal-9-Readiness

Procedure for fixing the problems

  1. Select a specific deprecation and check if a child issue has been created for this
  2. If there is no issue, create one and set this issue 3042677 as the parent
  3. In the issue title include the function or class or process that is being replaced
  4. In the issue summary include a link to the Change Record and/or API documentation that show the details of the deprecation
  5. Add a comment to this thread to alert others of the new issue
  6. If you want to work on the new issue then assign it to yourself
  7. When the issue is fixed and committed, please re-run the report and update the issue summary here so that we can see what still remains left to do

Latest Report

8 April 2020

-----------------------------------------------------------
[OK] No errors
-----------------------------------------------------------                                                                                              
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Adrianm6254 created an issue. See original summary.

jonathan1055’s picture

Hi Adrianm6254,
You have pasted a huge list of text in the issue summary without any explanation. Could you reference #3035104: [meta] Remove deprecated code flagged by @trigger_error messages for Drupal 9 compatibility and give details of how you created this report.
Thanks.

joelpittet’s picture

Issue tags: +Novice, +Seattle2019

Tagging for DrupalCon Seattle Friday contribution sprint.

See https://github.com/mglaman/drupal-check/wiki/Drupal-9-Readiness

jonathan1055’s picture

I'm interested to know why, when we run the tests on #3035104: [meta] Remove deprecated code flagged by @trigger_error messages for Drupal 9 compatibility which have deprecations not suppressed via the patch:

+++ b/drupalci.yml
@@ -25,3 +25,4 @@ build:
     testing:
       run_tests.standard:
         types: 'PHPUnit-Functional'
+        suppress-deprecations: false

we do not see any of the errors mentioned in the text report in the issue summary.

mikelutz’s picture

There are a number of deprecated methods and classes in core that do not yet trigger an error when used. Prior to 8.4 we didn't have the coherent deprecation policy that we do now. drupal-check performs a static analysis and detects deprecated code usage through the @deprecated tags and provides a more thorough report.

We are working hard in core to add @trigger_errors to the remaining deprecated code paths, but in the meantime, this tool helps bridge the reporting gap.

jonathan1055’s picture

Hi mikelutz, thanks for the explanation. Yes I thought it might be something like that, but good to have it explained.

I've been active on #3024461: Adopt consistent deprecation format for core and contrib deprecation messages and am currently working on coder sniffs for #2908391: Add a rule for expected format of @deprecated and @trigger_error() text. So when more core code is properly deprecated at least now we have an agreed standard for how to do it.

bajah1701’s picture

How should we proceed with this? Should a patch be created for each file that is fix, or should there be one large patch for all the deprecations? I have created a number of patches but I'm not sure what is the maintainer's preference. Please let me know how I can help.

jonathan1055’s picture

Hi bajah1701,
Thanks for asking the question. I suggest that we create a separate issue for each type of fix/replacement, and each patch only needs to address one problem but will cover all the files that need that fix.

Jonathan
(scheduler maintainer)

bajah1701’s picture

Thanks for the guide, I will proceed as described.

maliknaik’s picture

Issue summary: View changes
maliknaik’s picture

jonathan1055’s picture

Thanks for adding the child issue.

Did you know that you can refer to issues using the syntax [#issuenumber] and this will be rendered with the full title, and coloured according to status, making it easier to see which issue is being linked. So [ #3049638] becomes #3049638: Replace call to deprecated function format_date

[edit: I see you have edited your comment above to use this syntax. It is useful]

tatarbj’s picture

Issue tags: +DrupalCampBelarus2019
jonathan1055’s picture

Thanks tatarbj for tagging.

For anyone wanting to participate, I suggest the process we follow is:

  1. Select the specific deprecation that you want to work on
  2. Create a separate issue and set this issue 3042677 as the parent
  3. When that issue is fixed and committed, please re-run the report and update the issue summary here
  4. Add a comment with the other issue showing that it is fixed, to let others following here know of the progress being made
e.bogatyrev’s picture

Assigned: Unassigned » e.bogatyrev
e.bogatyrev’s picture

Assigned: e.bogatyrev » Unassigned
jonathan1055’s picture

Issue summary: View changes

Created new issue #3055644: Replace calls to assertFieldById() as an example child issue. Anyone is welcome to work on it, just assign it to yourself first, to avoid someone else duplicating your work.

Updated issue summary with the process.

jonathan1055’s picture

Issue summary: View changes

Added more info to issue summary and expanded the procedure for fixing.

jonathan1055’s picture

Issue tags: +D9Readiness

Added D9Readiness tag so that this issue can be picked up on the report created by the Upgrade Status module, which is a wrapper for the drupal-check processing.

jonathan1055’s picture

Issue summary: View changes

The following messages no longer appear in the updated report, not because we have fixed them all, but because of #3031580: Undeprecate \Drupal\FunctionalTests\AssertLegacyTrait and \Drupal\KernelTests\AssertLegacyTrait in Drupal 8 - recording them here, and have updated the issue summary with latest report.

Call to deprecated method assert() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertFieldById() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertFieldByName() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertLink() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertLinkByHref() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertNoFieldById() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertNoFieldByName() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertNotEqual() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertNoText() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertResponse() of class Drupal\Tests\BrowserTestBase.
Call to deprecated method assertText() of class Drupal\Tests\BrowserTestBase.
jonathan1055’s picture

Kristen Pol’s picture

Issue tags: -D9Readiness

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.

jonathan1055’s picture

Issue summary: View changes

The Call to deprecated function drush_get_option() warning seems to have disappeared in current runs.

chr.fritsch’s picture

Status: Active » Needs review
FileSize
2.94 KB

Here is a patch to fix the last remaining deprecation and make the module D9 ready

jonathan1055’s picture

Thanks chr.fritsch, however, as per the instructions in the issue summary, the changes need to be in separate child issues to allow them to be tested independetly and then fixed and closed.

We already have #3079913: Add new 'core_version_requirement' key to .info.yml so I have now created #3105354: Replace deprecated entity_delete_multiple() to deal with the other change in your patch.

jonathan1055’s picture

Issue summary: View changes
Status: Needs review » Active
Issue tags: -midcamp2019, -Novice, -Seattle2019, -DrupalCampBelarus2019

Now that #3105354: Replace deprecated entity_delete_multiple() is fixed, according drupal-check we have no D9 deprecation warnings!

Abhijith S’s picture

Patch cannot be installed as it is showing this error

$ git apply -v 3042677.patch
Checking patch scheduler.info.yml...
Checking patch scheduler_rules_integration/scheduler_rules_integration.info.yml...
Checking patch tests/modules/scheduler_access_test/scheduler_access_test.info.yml...
Checking patch tests/modules/scheduler_api_test/scheduler_api_test.info.yml...
Checking patch tests/modules/scheduler_api_test/scheduler_api_test.install...
error: while searching for:
->condition('n.type', ['scheduler_api_test'], 'IN')
->execute();
if ($nids = $nids_query->fetchCol()) {
entity_delete_multiple('node', $nids);
\Drupal::messenger()->addMessage(t('@number %type node(s) have been deleted.', [
'@number' => count($nids),
'%type' => 'scheduler_api_test',

error: patch failed: tests/modules/scheduler_api_test/scheduler_api_test.install:21
error: tests/modules/scheduler_api_test/scheduler_api_test.install: patch does not apply

jonathan1055’s picture

Status: Needs work » Active

Hi Abhijith S
You have mis-understood. That patch in #24 should not have been added here, please read my comment in #25 and look at those two other issues.
Jonathan

jonathan1055’s picture

From deprecation-checking-and-correction-tools

The same PHPStan deprecation testing tool can run on your project (similar to drupal-check and Upgrade Status' backend). This will produce a build artifact but will not (yet) fail the testing of your project.

So here is a patch for drupalci.yml to try it.

DamienMcKenna’s picture

Title: Drupal 9 Deprecated Code Report » Drupal 9 Deprecated Code Report for Scheduler
Status: Active » Needs review
jonathan1055’s picture

I have committed the patch in #30 (but attached it to the wrong issue). Anyway, we will now get PHPstan output on every d.o. test run, so we can check easily if we are using any newly deprecated code not flagged with @trigger_error

jonathan1055’s picture

Hide the patch that is no longer needed.

jonathan1055’s picture

Trial patch to remove the interactive progress output on PHPSTAN. This has odd graphics characters which cause a minor iritation when downloading the jenkins dispatcher logs to compare test runs.

16:08:30   0/70 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
[2K 60/70 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░]  85%
[2K 70/70 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

The syntax to use is a bit of guess-work. Let's see ...

jonathan1055’s picture

Issue summary: View changes

Still clean.

jonathan1055’s picture

vuil’s picture

Status: Needs review » Reviewed & tested by the community

It has to be published, hopefully soon. 🙏 I set the issue status to RTBC.

jonathan1055’s picture

Status: Reviewed & tested by the community » Active

@vuil I think you must have posted to the wrong issue, as there is nothing to commit here.

DamienMcKenna’s picture

The current codebase appears to be fully compatible, maybe time to mark this "fixed"?

jonathan1055’s picture

Status: Active » Fixed

Yes, both scheduler 2.x and 8.x-1.x branches have no deprecations for Drupal 9 (and have been clean for a long time)

Status: Fixed » Closed (fixed)

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