This issue is created based on the documentation page Help contributed modules prepare for Drupal 9. It's not meant to be committed, but used as an ongoing issue to make deprecations visible.

1. Read Gábor Hojtsy's blog post on checking for compatibility with Drupal 9 as it provides a patch that applies to any module because it just adds a new file.

2. Create an issue in a module, name it "Test for deprecations" or so, then let the tests run with that patch. You might want to run it against latest core (currently 8.7.x) by adding an explicit test run as quite a few new deprecations messages have been added there. but you should be careful to only update deprecations that are safe to do for all supported drupal core versions, e.g. currently deprecated in Drupal 8.4.0 or earlier.

3. Based on the amount of results you get from that, you could either create a single new issue to update them all (should be fine for smaller modules) or split them up, e.g. if a module has a lot of db_* functions, or entity related stuff, you could group that together. Either way, you should do that in a new issue, because that allows to keep the "Test for deprecations" issue open, then that can simply be re-tested after the patches have been committed and then again some time later to see if there's new stuff.

4. If the module does not yet have an explicit dependency in its info.yml file, you should add that, e.g. "drupal:system (>= 8.5)" to make sure that people can't install the new version on an older core version.

Not everything does use @trigger_error() yet, but more and more does. Focusing on these things first also has the most benefit, because every @trigger_error() has a small performance impact as well.

Comments

thalles created an issue. See original summary.

thalles’s picture

StatusFileSize
new662 bytes

Follow the patch!

thalles’s picture

Status: Needs review » Needs work

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

jonathan1055’s picture

Thanks for this. You read my mind as I was about to do this - see #3033376: Add drupalci.yml test file to configure d.o. testing
I was planning to add a default drupalci.yml so when that is done I was going to make the change to run without hiding the deprecations.

The results above match my Travis test builds on
https://travis-ci.org/jonathan1055/scheduler/branches which is good.

By the way, the link in the issue summary does not work. I think you truncated the url.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new662 bytes

No that #3034805: Using setPublished() with a $published parameter is deprecated in 8.3 the number of deprecation fails should be lower.

Status: Needs review » Needs work

The last submitted patch, 6: 3035104-6.drupalci.yml.patch, failed testing. View results

thalles’s picture

The link broke in the last few days, then I'll check with @berdir, I think he can help with this.

Thanks!

jonathan1055’s picture

Issue summary: View changes

Fixed the link to Gábor Hojtsy's blog post.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new381 bytes

Now that we have a default drupalci.yml added in #3033376-5: Add drupalci.yml test file to configure d.o. testing here is a patch which just adds the "suppress-deprecations: false" configuration option.

Status: Needs review » Needs work

The last submitted patch, 10: 3035104-10.scheduler-show-deprecations.patch, failed testing. View results

jonathan1055’s picture

Had 5 fails before, but now that #3034986: Replace deprecated SafeMarkup::checkPlain() is in, I've requeued the patch in #10

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new250 bytes

Of course, the drupalci.yml file has been changed since that last patch.

Status: Needs review » Needs work

The last submitted patch, 13: 3035104-13.scheduler-show-deprecations.patch, failed testing. View results

jonathan1055’s picture

Status: Needs work » Needs review

That's good. We've removed the four deprecation fails from #3034986: Replace deprecated SafeMarkup::checkPlain() and now just have the one covered by
#3035911: EntityInterface::link() is deprecated, replace with EntityInterface::toLink()

jonathan1055’s picture

Ha! No sooner had we removed the last deprecation via #3035911: EntityInterface::link() is deprecated, replace with EntityInterface::toLink() then Core deprecate something else (almost exactly at the same time). Luckily I had two days of clean test results on TravisCi as I pushed the checkPlain() fixed there earlier than to d.o.

I have raised #3038746: Remove deprecated EntityDefinitionUpdateManagerInterface::applyUpdates() from hook_install and hook_uninstall for the new deprecation.

jonathan1055’s picture

Now that #3038746: Remove deprecated EntityDefinitionUpdateManagerInterface::applyUpdates() from hook_install and hook_uninstall is done, we should get clean tests with no deprecation warnings. Re-queueing patch #13

jonathan1055’s picture

Status: Needs review » Reviewed & tested by the community

Setting this to RTBC (even though the patch is not intended to be committed) just to see if that causes the patch to be automatically re-tested periodically.

thalles’s picture

Congratulations @jonathan1055!

jonathan1055’s picture

I re-ran the patch today and we had one failure, in DefaultTimeTest. The test failure is very likely to be due to #2957490: Default time tests fail in run-up to Daylight Saving clock change.

jonathan1055’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 3035104-13.scheduler-show-deprecations.patch, failed testing. View results

jonathan1055’s picture

Category: Feature request » Task
Status: Needs work » Active

Fixed #3048600: Drupal::url() is deprecated, replace with \Drupal\Core\Url object and now the tests are green and all passing with no @trigger_error warnings.

jonathan1055’s picture

Title: [meta] Remove deprecated code in preparation for D9 » [meta] Remove deprecated code flagged by @trigger_error messages

Renaming to make this issue more distinct from #3042677: Drupal 9 Deprecated Code Report for Scheduler

jonathan1055’s picture

New deprecation #3059741: Replace deprecated entityManager() with entityTypeManager() which is now actually triggers a warning.

jonathan1055’s picture

StatusFileSize
new250 bytes

Using PHP 7.1, MySQL 5.7, D8.8 On 5th June - working fine. 6th June - we get

warning: drupalci.yml has type 100644, expected 100755
error: patch failed: drupalci.yml:25
error: drupalci.yml: patch does not apply

Here is the same patch but with index 9608ac7..b401dbf 100755 manually changed to index 9608ac7..b401dbf 100644

jonathan1055’s picture

OK that fixed the 100755/100644 problem but that was not the main thing. The patch still fails because this change is already in the drupalci.yml file - I committed it in #3059741-3: Replace deprecated entityManager() with entityTypeManager()

So, there is no patch here on this issue now. We can keep it open as a Meta issue if that is useful. We will get alerted to any deprecation triggers via the daily automated testing.

  • jonathan1055 committed cd5134a on 8.x-1.x
    Issue #3035104 by jonathan1055, thalles: Reset suppress-deprecations:...
jonathan1055’s picture

I have reset the drupalci.yml config to suppress-deprecations: true as we do not really want the tests on drupal.org to be showing failures on the project front page whenever a new deprecation trigger is commited to core.

https://travis-ci.org/jonathan1055/scheduler is set to alert me with a failure for any use of deprecated code, and will create child issues here to fix them.

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.

jonathan1055’s picture

For info on #3079913: Add new 'core_version_requirement' key to .info.yml I have just committed this which adds core_version_requirement to the two main module .info.yml files (not the test modules)

jonathan1055’s picture

Adding parent. Not all deprecations are for D9 but most are.

jonathan1055’s picture

StatusFileSize
new483 bytes

Re-rolled patch #26 to show deprecations

  • jonathan1055 committed 048910e on 8.x-1.x
    Issue #3035104 by jonathan1055: Increase allowed deprecations at 9.1 due...

  • jonathan1055 committed 5e3ef96 on 8.x-1.x
    Issue #3035104 by jonathan1055: Allow for 23 new deprecations in Rules...

  • jonathan1055 committed 1bcefc6 on 2.x
    Issue #3035104 by jonathan1055: Adjust allowed deprecation counts on...
jonathan1055’s picture

Version: 8.x-1.x-dev » 2.x-dev
Issue tags: -Drupal 9 compatibility

Moving to the 2.x branch to assist with Drupal 10 preparation

jonathan1055’s picture

Title: [meta] Remove deprecated code flagged by @trigger_error messages » [meta] Remove deprecated code flagged by @trigger_error messages for Drupal 9 compatibility
Version: 2.x-dev » 8.x-1.x-dev
Status: Active » Fixed

Actually, this is all about Drupal 9 so marking this fixed.

Status: Fixed » Closed (fixed)

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