Problem/Motivation
The following coding standards and code deprecations are present in the codebase:
Coding Standards:
FILE: ...odules/contrib/advancedqueue/src/Plugin/views/field/JobState.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
49 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: ...advancedqueue_test/src/Plugin/AdvancedQueue/JobType/Flexible.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
31 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
32 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: ...eue/tests/modules/advancedqueue_test/advancedqueue_test.info.yml
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
1 | WARNING | "Description" property is missing in the info.yml file
----------------------------------------------------------------------
Time: 1.73 secs; Memory: 14MB
Drupal Deprecations introduced in 9.0 and 9.1:
Remaining self deprecation notices (42)
22x: Calling the Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch() method with a string event name as the first argument is deprecated in drupal:9.1.0, an Event object will be required instead in drupal:10.0.0. See https://www.drupal.org/node/3154407
8x in ProcessorTest::testProcessor from Drupal\Tests\advancedqueue\Kernel
8x in ProcessorTest::testRetry from Drupal\Tests\advancedqueue\Kernel
6x in ProcessorTest::testTimeLimit from Drupal\Tests\advancedqueue\Kernel
4x: Declaring ::setUp without a void return typehint in Drupal\Tests\advancedqueue\Kernel\ProcessorTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
4x in DrupalListener::startTest from Drupal\Tests\Listeners
4x: The Drupal\Tests\advancedqueue\Kernel\ProcessorTest::$modules property must be declared protected. See https://www.drupal.org/node/2909426
4x in DrupalListener::startTest from Drupal\Tests\Listeners
3x: Declaring ::setUp without a void return typehint in Drupal\Tests\advancedqueue\Functional\QueueTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
3x in DrupalListener::startTest from Drupal\Tests\Listeners
3x: The Drupal\Tests\advancedqueue\Functional\QueueTest::$modules property must be declared protected. See https://www.drupal.org/node/2909426
3x in DrupalListener::startTest from Drupal\Tests\Listeners
3x: Declaring ::setUp without a void return typehint in Drupal\Tests\advancedqueue\Kernel\DatabaseBackendTest is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724
3x in DrupalListener::startTest from Drupal\Tests\Listeners
3x: The Drupal\Tests\advancedqueue\Kernel\DatabaseBackendTest::$modules property must be declared protected. See https://www.drupal.org/node/2909426
3x in DrupalListener::startTest from Drupal\Tests\Listeners
Steps to reproduce
1. Scan codebase with phpcs using Drupal Coding Standards. (coding standards issues)
2. Execute module's unit tests with PHP 7 or higher, using Drupal 9.1 or higher as a base install.
Proposed resolution
Patch to address both codings standards and Drupal deprecations is attached. This patch will remove support for Drupal 8, which was deprecated in November 2021.
| Comment | File | Size | Author |
|---|---|---|---|
| drupal-9-deprecations.patch | 5.42 KB | lisa.rae |
Issue fork advancedqueue-3262956
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
lisa.rae commentedComment #3
benjifisher@lhridley:
Thanks for working on this issue!
When you upload a new patch, please follow the Patch naming conventions. Usually, when I have already done the work before opening an issue, I create the issue so that I know the issue number, then create and upload the patch.
Alternatively, create a merge request (MR) instead of a patch. See Creating issue forks and merge requests. One advantage of a MR is that it gives an easy way to test the changes with an actual Drupal 10 site: see Testing A Drupal 8 Module On Drupal 9 in the Fruition blog.
If you attach a patch to Comment #4, then the recommended file name will be something like
advancedqueue-drupal-10-compatibility-3262956-4.patch. Or at least3262956-4.patch.I ran
phpcsand also used the report from the Upgrade Status module before and after applying the patch. I also reviewed the patch manually, and I ran the module's PHPUnit tests. I have just three comments:After this change, the module would still not be compatible with Drupal 10. I think we should use
^9.1 || ^10. For the record: we need 9.1 and not just 9 becauseDrupal\Component\EventDispatcher\Eventwas added in Drupal 9.1.Really minor point: removing the blank line makes the diff a little harder to compare (at least the way I review diffs).
The Upgrade Status report also complains about the three classes in the Drupal\advancedqueue\Command namespace, which use Drupal Console classes (Drupal\Console namespace). I think it is safe to leave these classes where they are, but one of us should add an issue to convert them to Drush commands, unless Drupal Console releases a version compatible with Drupal 10.
Comment #4
benjifisherTrue. As #3.1 and #3248140-4: Symfony 4.4 event dispatcher parameter order change point out, the changes here require at least Drupal 9.1, so there is no point in claiming D8 compatibility in the .info.yml file.
It might make sense for the maintainers to open a new branch (8.x-2.x or 2.0.x) including a fix for this issue, so that they can continue working on a full release to support those sites that are still using D8 after EOL while also working towards D10.
Looking at the issue queue, I see about 2 dozen issues for the 8.x-1.x branch, but
I see there is already a roadmap issue: #3220292: Roadmap to 1.0 lists just 3 issues (NR, NR, NW) standing in the way of a full release.
Comment #5
lisa.rae commentedThanks for reviewing @benjifisher!
Naming conventions for patch: Apologies, forgot to rename the patch before submitting it. Duly noted.
Using MR vs Patch: Completely slipped my mind that this was an option. Until additional refactoring this module fails testing with Drupal 10 (see notes below on D 10 compatibility), primarily because you need Drush 11 in place for Drupal 10 (at least, my testing refused to install any modules on D10 without Drush 11).
Drupal 10 compatibility: This patch was not intended to address Drupal 10 compatibility, but to fix the deprecation notices and coding standards issues present in the current Drupal 9 codebase. There are additional items to refactor to make the project Drupal 10 compatible, including removing the Drupal Console commands and fixing some issues with the Drush commands that are due to deprecated functionality in Drush that has been removed in Drush 11.
Removing support for Drupal 8: I specifically called this out so that the module maintainers could make a decision on whether to create a new branch.
Drupal Console: Given that the project has more or less been abandoned (no work since November 2019) in favor of Drush, this refactoring should be either done independently, or in conjunction with refactoring for Drupal 10 compatibility.
Comment #6
lisa.rae commentedComment #7
victoria-marina commentedAwaiting the new changes to review.
Comment #8
victoria-marina commentedComment #10
lisa.rae commentedComment #11
lisa.rae commentedMR created on Gitlab, replaces original submitted patch.
Please note related issue removing Drupal Console commands. This has been opened as a separate issue to give any users who use Drupal Console to check and replace any functionality that removing those commands removes from the module with Drush commands that provide replacement functionality.
Comment #12
victoria-marina commentedI'll review this.
Comment #13
victoria-marina commentedAfter the last commit, the
EventDispatcher::dispatch()argument order was correctly changed.Comment #16
bojanz commentedGreat job, everyone!