------ --------------------------------------------------------------------------- 
  Line   src/Plugin/TfaSetup/GALoginHotpSetup.php                                   
 ------ --------------------------------------------------------------------------- 
  185    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
 ------ --------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------- 
  Line   src/Plugin/TfaSetup/GALoginTotpSetup.php                                   
 ------ --------------------------------------------------------------------------- 
  182    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
 ------ --------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------- 
  Line   tests/src/Functional/GALoginHotpValidationPluginTest.php                   
 ------ --------------------------------------------------------------------------- 
  108    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
  132    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
 ------ --------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------- 
  Line   tests/src/Functional/GALoginTotpValidationPluginTest.php                   
 ------ --------------------------------------------------------------------------- 
  108    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
  141    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
 ------ --------------------------------------------------------------------------- 
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Suresh Prabhu Parkala’s picture

Status: Active » Needs review
FileSize
6.8 KB

Please review the patch file. Thank you.

jcnventura’s picture

Status: Needs review » Needs work

Best replacement for User::getUsername without risk of breaking the current code is $account->getAccountName().

jcnventura’s picture

Status: Needs work » Needs review
FileSize
7.23 KB
8.88 KB

It seems clear to me that #2 was never actually tested. The only way for TfaValidationPluginManager to call the create() function is to make these TfaBasePlugin-derived classes extend the ContainerFactoryPluginInterface.

Also replaced the wrong replacement of User::getUsername() with User::getAccountName().

jcnventura’s picture

Issue tags: +Drupal 9 compatibility
jcnventura’s picture

Issue summary: View changes

Some more deprecations that were not detected originally:

 ------ --------------------------------------------------------------------------- 
  Line   tests/src/Functional/GALoginHotpValidationPluginTest.php                   
 ------ --------------------------------------------------------------------------- 
  108    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
  132    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
 ------ --------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------- 
  Line   tests/src/Functional/GALoginTotpValidationPluginTest.php                   
 ------ --------------------------------------------------------------------------- 
  108    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
  141    Call to deprecated method getUsername() of class Drupal\user\Entity\User:  
         in drupal:8.0.0 and is removed from drupal:9.0.0.                          
         Use \Drupal\Core\Session\AccountInterface::getAccountName() or             
         \Drupal\user\UserInterface::getDisplayName() instead.                      
 ------ --------------------------------------------------------------------------- 
jcnventura’s picture

This is also changing the visibility of GALoginRecoveryCodeSetup::generateCodes() from protected to public, as the parent class defines this method as public, and this can't be overridden here.

divyesh19’s picture

Status: Needs review » Reviewed & tested by the community

Patch #7 looks good and applies cleanly.
Installed module successfully after applying patch on D8.8.7 as well as D9.

acbramley’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/src/Plugin/TfaValidation/GALoginHotpValidation.php
@@ -72,15 +75,22 @@ class GALoginHotpValidation extends TfaBasePlugin implements TfaValidationInterf
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, UserDataInterface $user_data, EncryptionProfileManagerInterface $encryption_profile_manager, EncryptServiceInterface $encrypt_service, ConfigFactoryInterface $config_factory, TimeInterface $time) {

+++ b/src/Plugin/TfaValidation/GALoginTotpValidation.php
@@ -72,16 +75,23 @@ class GALoginTotpValidation extends TfaBasePlugin implements TfaValidationInterf
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, UserDataInterface $user_data, EncryptionProfileManagerInterface $encryption_profile_manager, EncryptServiceInterface $encrypt_service, ConfigFactoryInterface $config_factory, TimeInterface $time) {

These constructor changes need to be applied to GALoginTotpSetup, GALoginHotpSetup, and GALoginRecoveryCodeSetup as well.

acbramley’s picture

Status: Needs work » Needs review
FileSize
15.35 KB
3.89 KB

Fixes #9

  • acbramley authored 5740fd0 on 8.x-1.x
    Issue #3120760 by jcnventura, acbramley, Suresh Prabhu Parkala,...
jcnventura’s picture

Status: Needs review » Fixed
acbramley’s picture

Thank you @jcnventura! Any chance we can get a new release for this?

Status: Fixed » Closed (fixed)

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