Problem/Motivation
I noticed there are quite some deprecations in the module, some of which actually prevent D9 usage.

Steps to reproduce
Run the deprecated PHP code report on the module.
Proposed resolution
Refactor all code so the deprecations are resolved.
Remaining tasks
- Resolve deprecations in .drush.inc
- Resolve deprecations in .module
- Resolve deprecations in WidgetBlockLazyBuilder
- Resolve deprecations in WidgetBlockListBuilder
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | made-changes-for-d9-compatibility-3198792-20.patch | 5.94 KB | økse |
| #19 | made-changes-for-d9-compatibility-3198792-19.patch | 5.94 KB | gugalamaciek |
| #10 | Screenshot from 2021-08-26 12-25-09.png | 149.92 KB | gugalamaciek |
| Screenshot 2021-02-16 at 21.11.14.png | 137.04 KB | bramdriesen |
Issue fork widget_block-3198792
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
stefaniev commented+1 for this. Deprecations prevent usage in D9.
Comment #3
bramdriesenTagging it as novice since it's not a difficult task.
Comment #4
bramdriesenComment #5
anjali rathodComment #6
anjali rathodPlease review and add comments . I have made changes and added a patch.
Comment #7
bramdriesenFor Drupal versions 8.4+ & 9 we need to support Drush 9/10 (best to go for 10). This means the drush command needs to be refactored as well since it's no longer working with .inc files.
Comment #8
grgcrlsn321 commented@Anjali Rathod
I ran your patch, but received the following errors,
Checking patch src/WidgetBlockLazyBuilder.php...
Checking patch src/WidgetBlockListBuilder.php...
Checking patch widget_block.drush.inc...
error: while searching for:
<?php
/**
* @file
* Widget Block drush integration.
error: patch failed: widget_block.drush.inc:1
error: widget_block.drush.inc: patch does not apply
But then ran the same command with, git apply -v --reject --whitespace=fix
and everything looks good that applied, I will check with drupal-check command
Checking patch src/WidgetBlockLazyBuilder.php...
Checking patch src/WidgetBlockListBuilder.php...
Checking patch widget_block.drush.inc...
error: while searching for:
<?php
/**
* @file
* Widget Block drush integration.
error: patch failed: widget_block.drush.inc:1
Hunk #2 succeeded at 62 (offset -2 lines).
Hunk #3 succeeded at 77 (offset -2 lines).
Hunk #4 succeeded at 99 (offset -2 lines).
Hunk #5 succeeded at 124 (offset -2 lines).
Hunk #6 succeeded at 155 (offset -2 lines).
Applied patch src/WidgetBlockLazyBuilder.php cleanly.
Applied patch src/WidgetBlockListBuilder.php cleanly.
Applying patch widget_block.drush.inc with 1 reject...
Rejected hunk #1.
Hunk #2 applied cleanly.
Hunk #3 applied cleanly.
Hunk #4 applied cleanly.
Hunk #5 applied cleanly.
Hunk #6 applied cleanly.
Comment #9
grgcrlsn321 commentedBefore patch applied errors with drupal-check
After patch was applied,
Comment #10
gugalamaciek commentedI found two more deprecations:
Patch updated
Comment #11
bramdriesenThe drush command still needs to be refactored (#7)
Comment #13
saidatomComment #15
saidatomCheck https://git.drupalcode.org/project/widget_block/-/merge_requests/3 #14
Comment #16
bramdriesenSome things could be cleaned up with dependency injection, but those should not be a show stopper to get this merged!
Comment #17
stefaniev commentedThe patch applies, but after updating to Drupal 9.0, I get the following error when using Drush to clear the cache:
The service "widget_block.lazy_builder" has a dependency on a non-existent service "entity.manager".
Comment #18
bramdriesenDid you try the patch from #10 or the patch based on the pull request of #14 (https://git.drupalcode.org/project/widget_block/-/merge_requests/3.patch) ?
Comment #19
gugalamaciek commented@StefanieV please try #19 :) I forgot to change
entity.managertoentity_type.managerinwidget_block.services.ymlComment #20
stefaniev commented@BramDriesen, I tried the patch from #10.
@gugalamaciek, great, thanks, the patch from #19 works!
Thanks for all the effort!
Comment #21
økse commentedI rerolled the patch against 8.x-1.3-rc1.