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
Issue fork linkchecker-3271896
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 #3
eiriksmComment #4
eiriksmComment #5
eiriksmComment #6
eiriksmComment #7
eiriksmComment #8
Johnny Santos commentedI'm going for it.
Comment #9
Johnny Santos commentedRemoved all deprecated from module(two files: linkchecker.install and QueueWorker/LinkCheck.php) as well as deprecated code on /tests.
Comment #10
kimberlly_amaral commentedI'll review that.
Comment #11
kimberlly_amaral commentedI removed the remaining comments with deprecations.
Comment #12
eiriksmThe messages meant to be displayed when assertions fail seem to be removed in several cases. Can we fix that? 🤓✌️
Comment #13
Johnny Santos commentedGoing for it, as described in comment #12
Comment #14
Johnny Santos commentedI 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.
Comment #15
Johnny Santos commentedForgot to Unassign
Comment #16
eiriksmThanks. 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!
Comment #17
Johnny Santos commentedThanks for all the indications!
Going for it.
Comment #18
Johnny Santos commentedOn 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 "
Comment #19
eiriksmI just re-did all those assertions like I wanted them myself.
Leaving as needs review since I now have committed things myself.
Comment #20
c-logemannJust made clear that we are going to be d10 compatible. I will also add this issue to project page.
Comment #21
bruno.bicudoI reviewed and tested (both running all tests and manually testing through the UI) and everything seems ok, so moving to RTBC :)
Comment #24
vladimirausPushed few updates from #3288332: Automated Drupal 10 compatibility fixes
To test module on Drupal 10
1. Add to
composer.jsonrepositories section. Make sure it is added beforehttps://packages.drupal.org/82. Run composer command
Comment #25
vladimirausAfter trying to install getting error
Comment #26
vladimirausInstallable and working. Please review.
Comment #28
jannakha commentedFix required for test:
PHP 8.1 & MySQL 5.7, D10.1 85 pass, 1 fail
Comment #29
acbramley commentedFixed 2 spots that were throwing deprecation errors on PHP 8.1.
Coming from an empty URL in the presave
and
Coming from an empty hash in updateSameLinks
Comment #30
joseph.olstad@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
Comment #31
joseph.olstadPHP 8.2 fixes needed, (easy to fix)
Missing $cron property, add it.
public $cron;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;again in:
again in
again in
again in
again in
Comment #33
vladimirausThanks 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. 🙋♀️
Comment #34
vladimirausComment #35
joseph.olstad#3335586: Dynamic properties are deprecated in PHP 8.2