This is blocked on #3461478: Drupal 11 compatibility

Modernize the whole CAS module codebase:

  • Strict type all class protected/private properties
  • Where possible, strict type all functions/methods parameters
  • Where possible, strict type all functions/methods returns
  • Use autowiring and autoconfiguring where possible to simplify services, plugins, and service definitions
  • Replace annotations with PHP attributes, where possible

Release notes

Compatibility

CAS 3.0.0 is compatible with Drupal 10.3, 10.4 and 11.0

Updating to CAS 3.0.0

  • While still on Drupal 10, update your site to CAS 2.3.2. This is very important because starting with CAS 3.0.0, old (post)update functions are removed.
  • Require drupal/cas:^3.0 with Composer
  • If you have custom code that interacts with the CAS module, you may need to make some updates. There are some tiny backwards compatibility breaking changes that require your attention:
    • The type of value returned by CasLoginException::getCode() was changed from integer to enum of type CasLoginExceptionType. If your code calls this method, you should adapt. If you still need the integer value, you can do something like
      $codes = CasLoginExceptionType::cases();
      $code = array_search($exception->getCode(), $codes, TRUE);
      
    • The parameter of CasUserManager::getCasUsernameForAccount() is now strict typed as integer. Make sure you cast the parameter to an Integer before is passed to the method:
      $account = ...;
      $uid = (int) $account->id();
      $name = \Drupal::service('cas.user_manager')->getCasUsernameForAccount($uid);
      
    • The CasServerConfig::setProtocolVersion() setter accepts now a CasProtocolVersion enum case as parameter instead of a string. Same, the CasServerConfig::getProtocolVersion() getter returns now a CasProtocolVersion enum case instead of a string. If needed, get the server version as a legacy string: CasServerConfig::getProtocolVersion()->value.
    • The CasServerConfig::setHttpScheme() setter accepts now a HttpScheme enum case as parameter instead of a string. Same, the CasServerConfig::getHttpScheme() getter returns now a HttpScheme enum case instead of a string. If needed, get the HTTP scheme as a legacy string: CasServerConfig:: getHttpScheme()->value.
    • The CasServerConfig::setVerify() setter accepts now a SslCertificateVerification enum case as parameter instead of an integer. Same, the CasServerConfig::getVerify() getter returns now a SslCertificateVerification enum case instead of an integer. If needed, get the certificate verification scheme as a legacy integer: CasServerConfig:: getVerify()->value.
  • You can now update your site to Drupal 11.

After updating to CAS 3.0.0

Prepare for the next CAS version by replacing the deprecated code. Check https://www.drupal.org/node/3462792 to learn what is deprecated in CAS 3.0.0 and adapt your code.

Issue fork cas-3462684

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

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Title: [PP-1] Modernize CAS module code » Modernize CAS module code
Status: Postponed » Needs work
bkosborne’s picture

This was a huge merge request, I reviewed it at a high level.

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Status: Needs work » Needs review

This is ready for a new review. Please take a look to issue summary where I've prepared the release notes for 3.0.0, because there are some tiny BC violations, but this is accepted between major releases according to semver.

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
bkosborne’s picture

Issue summary: View changes
bkosborne’s picture

Status: Needs review » Reviewed & tested by the community

Made some minor changes to the issue summary and reviewed the newer commits from yesterday. This looks good to me. This seems like it was a lot of work. I learned a lot about enums from reviewing the code! Such a better solution than what we used before!

claudiu.cristea’s picture

Issue summary: View changes

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for review.

Status: Fixed » Closed (fixed)

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