Massive code cleanup

Created on 2 January 2023, almost 2 years ago
Updated 21 January 2023, almost 2 years ago

Problem/Motivation

In trying to run some of the automated checks for Drupal 10, I found we had a lot of places where code style (and sometimes structure) could be tweaked a little.

Proposed resolution

The attached MR includes these:

Changes in the main SAML SP module

  • Removed deprecated saml_sp_menu() from saml_sp.module because that functionality is handled by the routing system.
  • Removed saml_sp.pages.inc because the routing system gets that functionality from SamlSPController (see API changes below).
  • New type hint and sample code in saml_sp.api.inc (see API changes below).
  • Added some assert() lines to entity forms to guarantee we are working with the kind of entity we expect.
  • Replaced deprecated functions in SamlSPController.php with their modern equivalents.
  • Minor rearrangement in the SamlSPConfig.php form definition to reduce the complexity of the conditionals around the metadata field.
  • Lots of comments got capital letters and punctuation.

Changes in the SAML SP Drupal Login submodule

  • Removed Drupal 8 and added Drupal 10.
  • Fixed a long-lingering typo/bug in saml_sp_drupal_login.module (we have $this instead of $user) which is in at least a couple patches on other issues that we haven’t merged yet.

Remaining tasks

None (for now): the module code currently passes both drupal-check and phpcs with no errors!

After merging we should check for merge conflicts in all the other open MRs.

API changes

New deprecation

Function saml_sp__is_valid_authentication_response() was in saml_sp.pages.inc; it was previously used by the consumer endpoint page. That page (and a copy of this function) is now in SamlSPController.php, and we do not need it outside of that context. Since I removed saml_sp.pages.inc, I moved the function to saml_sp.module and marked it deprecated for version 4.2.0 (whenever that gets released), to be removed in 5.0.0. When this MR is accepted I’ll start a 5.x branch to enact that.

API bug fixed

In saml_sp.api.inc, hook_saml_sp_settings_alter() specified a \OneLogin\Saml2\Settings object as its parameter, but the place where it’s invoked (in saml_sp__get_settings()) is working with an array. Actually calling the hook with an object would have had no effect, so I changed the parameter type to array.

📌 Task
Status

Fixed

Version

4.0

Component

Code

Created by

🇺🇸United States jproctor

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024