Problem/Motivation

We want to replace all deprecated code to be compatible with Drupal 9 and 10.

Steps to reproduce

Run tests locally. Or look at the test results from the first second commit to the MR: https://www.drupal.org/pift-ci-job/2347866

Proposed resolution

Replace all deprecations that are listed in the test results.

Remaining tasks

Fix

User interface changes

none

API changes

none

Data model changes

none

Command icon 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

eiriksm created an issue. See original summary.

eiriksm’s picture

Status: Active » Needs review
eiriksm’s picture

Issue tags: +Novice
eiriksm’s picture

eiriksm’s picture

Issue summary: View changes
eiriksm’s picture

Status: Needs review » Active
Johnny Santos’s picture

Assigned: Unassigned » Johnny Santos

I'm going for it.

Johnny Santos’s picture

Assigned: Johnny Santos » Unassigned
Status: Active » Needs review

Removed all deprecated from module(two files: linkchecker.install and QueueWorker/LinkCheck.php) as well as deprecated code on /tests.

kimberlly_amaral’s picture

Assigned: Unassigned » kimberlly_amaral

I'll review that.

kimberlly_amaral’s picture

Assigned: kimberlly_amaral » Unassigned

I removed the remaining comments with deprecations.

eiriksm’s picture

Status: Needs review » Needs work

The messages meant to be displayed when assertions fail seem to be removed in several cases. Can we fix that? 🤓✌️

Johnny Santos’s picture

Assigned: Unassigned » Johnny Santos

Going for it, as described in comment #12

Johnny Santos’s picture

Status: Needs work » Needs review

I observed that, previously, with the deprecated code, we were able to use 3 parameters, where the last one was used to return a message when the assertions fails.

Like here:
$this->assertFieldByName('path[0][alias]', '', 'Path input field present on add Basic page form.')

but now, this is not possible anymore.
Ending like this.

$this->assertSession()->fieldValueEquals('path[0][alias]', '')

I made some testes and I was able to go around that using Try,Catch.
as stated below:

try {
$this->assertSession()->fieldValueEquals(‘path[0][alias]‘, ‘’);
}
catch (\Throwable $th) {
$this->fail(‘Path input field present on add Basic page form.’);
}

Switching to review now,
If this is a viable solution, I can later add the Try/Catch plan to the code.

Johnny Santos’s picture

Assigned: Johnny Santos » Unassigned

Forgot to Unassign

eiriksm’s picture

Status: Needs review » Needs work

Thanks. Added some comments directly in the MR. We need to update a couple of assertions so the text we are looking for is identical to the old assertion.

Otherwise fantastic work!

Johnny Santos’s picture

Assigned: Unassigned » Johnny Santos

Thanks for all the indications!
Going for it.

Johnny Santos’s picture

Assigned: Johnny Santos » Unassigned
Status: Needs work » Needs review

On the way to meet the fix that was asked I was able to insert one more assertion in each of the files, however the valid assertion message I was not able to insert, since previously we had one more parameter in thoses functions reserved for that message. But it was removed.

You can check it here.

Calls to WebAssert methods do not allow more arguments than those in the signature
https://www.drupal.org/node/3162537

And if you insert anyway a third parameter, its prints a message saying that a second parameter is deprecated on drupal 9, and it will throw an exception on drupal 10.

from the terminal:

"OK (1 test, 49 assertions)

Remaining self deprecation notices (1)

1x: Calling Drupal\Tests\WebAssert::pageTextContains with more than one argument is deprecated in drupal:9.1.0 and will throw an \InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537 "

eiriksm’s picture

I just re-did all those assertions like I wanted them myself.

Leaving as needs review since I now have committed things myself.

c-logemann’s picture

Title: Fix deprecations for d9 » Prepare d10 compatibility

Just made clear that we are going to be d10 compatible. I will also add this issue to project page.

bruno.bicudo’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed and tested (both running all tests and manually testing through the UI) and everything seems ok, so moving to RTBC :)

JeroenT made their first commit to this issue’s fork.

VladimirAus made their first commit to this issue’s fork.

vladimiraus’s picture

Pushed few updates from #3288332: Automated Drupal 10 compatibility fixes

  • D10 version compatibilities

To test module on Drupal 10

1. Add to composer.json repositories section. Make sure it is added before https://packages.drupal.org/8

  "repositories": [
    ...
    {
      "type": "vcs",
      "url": "https://git.drupalcode.org/issue/linkchecker-3271896.git"
    },
    {
      "type": "composer",
      "url": "https://packages.drupal.org/8"
    },
    ...

2. Run composer command

composer require drupal/linkchecker:dev-3271896-fix-deprecations-for
vladimiraus’s picture

Status: Reviewed & tested by the community » Needs work

After trying to install getting error

Fatal error: Type of Drupal\linkchecker\Commands\LinkCheckerCommands::$logger must be ?Psr\Log\LoggerInterface (as in class Drush\Commands\DrushCommands) in /app-drupal/web/modules/contrib/linkchecker/src/Commands/LinkCheckerCommands.php on line 16
vladimiraus’s picture

Status: Needs work » Needs review

Installable and working. Please review.

acbramley made their first commit to this issue’s fork.

jannakha’s picture

Status: Needs review » Needs work

Fix required for test:
PHP 8.1 & MySQL 5.7, D10.1 85 pass, 1 fail

acbramley’s picture

Status: Needs work » Needs review

Fixed 2 spots that were throwing deprecation errors on PHP 8.1.

hash(): Passing null to parameter #2 ($data) of type string is deprecated

Coming from an empty URL in the presave

and

addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated

Coming from an empty hash in updateSameLinks

joseph.olstad’s picture

@Zombienaute managed to get the MR to pass on D10.0.1 / PHP 8.1, congrats!

I've triggered the PHP 8.2 tests with D10.0.1 now just to see how that's doing

joseph.olstad’s picture

PHP 8.2 fixes needed, (easy to fix)

Missing $cron property, add it.public $cron;

  1x: Creation of dynamic property Drupal\Tests\linkchecker\Kernel\LinkcheckerRedirectTest::$cron is deprecated
    1x in LinkcheckerRedirectTest::testLinkcheckerRedirect from Drupal\Tests\linkchecker\Kernel

Solution: Add a public property called $cron to LinkcheckerRedirectTest or it's parent class if that's easier

Missing $adminUser property, add it. public $adminUser;

  1x: Creation of dynamic property Drupal\Tests\linkchecker\Functional\LinkCheckerEditFormTest::$adminUser is deprecated
    1x in LinkCheckerEditFormTest::testEditUrlWorks from Drupal\Tests\linkchecker\Functional

again in:

  2x: Creation of dynamic property Drupal\Tests\linkchecker\Functional\LinkCheckerInterfaceTest::$admin_user is deprecated
    1x in LinkCheckerInterfaceTest::testLinkCheckerCreateNodeWithBrokenLinks from Drupal\Tests\linkchecker\Functional
    1x in LinkCheckerInterfaceTest::testLinkCheckerCreateBlockWithBrokenLinks from Drupal\Tests\linkchecker\Functional

again in

  1x: Creation of dynamic property Drupal\Tests\linkchecker\Functional\LinkCheckerLinkExtractionStatusTest::$adminUser is deprecated
    1x in LinkCheckerLinkExtractionStatusTest::testLinkCheckerStatusCorrect from Drupal\Tests\linkchecker\Functional

again in

  1x: Creation of dynamic property Drupal\Tests\linkchecker\Functional\LinkCheckerLinkExtractionTest::$adminUser is deprecated
    1x in LinkCheckerLinkExtractionTest::testLinkCheckerCreateNodeWithLinks from Drupal\Tests\linkchecker\Functional

again in

  2x: Creation of dynamic property Drupal\Tests\linkchecker\Functional\LinkCheckerOverviewTest::$adminUser is deprecated
    1x in LinkCheckerOverviewTest::testOverviewWorks from Drupal\Tests\linkchecker\Functional
    1x in LinkCheckerOverviewTest::testOverViewWorksWithResultFilter from Drupal\Tests\linkchecker\Functional

again in

  1x: Creation of dynamic property Drupal\Tests\linkchecker\FunctionalJavascript\LinkCheckerOverviewTest::$adminUser is deprecated
    1x in LinkCheckerOverviewTest::testOverviewWorks from Drupal\Tests\linkchecker\FunctionalJavascript

  • VladimirAus committed ccf4aa74 on 2.0.x
    Issue #3271896 by eiriksm, acbramley, VladimirAus, Johnny Santos,...
vladimiraus’s picture

Thanks everyone. 🍻

✅ closed #3288332: Automated Drupal 10 compatibility fixes as duplicate
✅ Branch 2.0.x is ready for D10 testing!

@joseph.olstad probably good idea to create PHP 8.2 compatibility as a separate task. 🙋‍♀️

vladimiraus’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Fixed
joseph.olstad’s picture

Status: Fixed » Closed (fixed)

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