Modernize CAS module code

Created on 19 July 2024, 3 months ago
Updated 7 August 2024, 2 months ago

This is blocked on πŸ“Œ Drupal 11 compatibility Fixed

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.

πŸ“Œ Task
Status

Fixed

Version

3.0

Component

CAS

Created by

πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024