Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Running drupal-check on simpleSAMLphp Authentication returns 11 errors:
- 7 calls to deprecated function drupal_set_message()
- 2 calls to deprecated method url() of class Drupal
2 uses of Class Drupal\Tests\UnitTestCase not found(not actually deprecated code)
Comment | File | Size | Author |
---|---|---|---|
#19 | simplesamlphp_auth-drupal-9-fixes-3047241-19.patch | 14.87 KB | oknate |
| |||
#19 | 3047241-interdiff--16-19.txt | 3.9 KB | oknate |
Comments
Comment #2
safetypinComment #3
safetypinI've completed an initial pass at replacing deprecated function calls for drupal_set_message() and \Drupal::url(). It looks to me like the "
...\UnitTestCase not found
" errors are false positives; I think you specify the location of this class when you run unit tests. But I'm not familiar with running Unit Tests on a Drupal module.Comment #4
BerdirChanges so far look good, would need to check the unit test stuff, could be bugs in phpstan or maybe those tests really are broken.
Comment #5
TR CreditAttribution: TR commentedRather than using the static \Drupal::messenger() call, the messenger service should be injected into SimplesamlphpDrupalAuth.php. It already has a number of other services injected, so this should be an easy fix.
I triggered testing of the patch in #3, and you can see from the output https://www.drupal.org/project/simplesamlphp_auth/issues/3047241 that you introduced one new coding standard violation, which should be fixed. The test failures seem to be branch failures unrelated to this patch.
Comment #6
safetypinHere's a new patch with the the coding standard violation fixed you mentioned (line 161 of SimplesamlphpDrupalAuth.php) - at least I'm pretty sure that's the one that I introduced. I've also added use MessengerTrait to the Class, which allows us to call $this->addMessage() directly. I think this isn't exactly what you had in mind, but it seems like a very elegant solution to me. I believe I'm using this correctly, but I'm not certain.
Comment #7
TR CreditAttribution: TR commentedIf you set the issue to needs review the test will be triggered automatically.
Comment #8
safetypinI looked at some other classes using the MessengerTrait, and applied that formatting to
SimplesamlphpDrupalAuth.php
.Comment #9
oknateThis update removes MessengerTrait and injects messenger service and module handler.
Comment #11
oknateUpdating the test.
Comment #12
oknateComment #13
TR CreditAttribution: TR commentedThis is an API change. It doesn't belong in this issue. I'm not sure why this change was included in this patch, because it has nothing to do with deprecated code.
This fixes one coding standards issue - line > 80 characters, but causes a new coding standards issue - function short description should be one line. Again, this is not a deprecated code problem so it should not be addressed here.
My comment in #5 did NOT mean that you should try to fix all the coding standards problems in the existing code - those should be handled in a separate issue. Instead, I simply meant that the patch should not introduce NEW coding standards issues.
What happened to the changes to SimplesamlphpDrupalAuthTest.php? They don't show up in your patch, but DO show up in your interdiff ...
What happened to the url() fixes?
What I was expecting was a patch similar to #8 but using injection instead of MessengerTrait.
Comment #14
oknateThe patch above was for #3052166: Coding style fixes. I was uploading a patch for this issue and one that issue, and I must have accidentally uploaded the wrong patch. The filename even references that issue.
That being said, that's some good feedback and I'll take that into account on the other issue.
Adding array type hint to simplesamlphp_auth_user_form_includes() isn't really an api change, because it's a helper function, you can't override it, and when you call it, you don't add a type hint, you'd use it like this:
simplesamlphp_auth_user_form_includes($form);
So the type hint wouldn't change the usage.
This is good feedback:
I'll fix that on issue 3052166.
Comment #15
oknateThe patch above was still wrong (same as 9, from wrong branch). Here's an update.
Comment #16
oknateFixing the php error.
Comment #17
oknateComment #18
BerdirLets also switch this to $this->() while touching these lines? Might have committed it, but it needs reroll anyway.
Comment #19
oknateComment #21
BerdirThanks, committed.