Problem/Motivation
Cannot access Verified Identities page (/admin/config/system/amazon_ses/settings/identities) if one or more AWS SES identities has not completed DKIM setup. (I know, the identity needs to be finalized, but we should at least not have a fatal error.)
Steps to reproduce
- Install module (v3.0.1, 3.0.x-dev)
- Configure AWS profile at /admin/config/services/aws
- Have at least one profile at AWS that does not have DKIM setup up
- Attempt to visit /admin/config/system/amazon_ses/settings/identities
- Receive error:
TypeError: reset(): Argument #1 ($array) must be of type array, null given in reset() (line 159 of modules/contrib/amazon_ses/src/AmazonSesHandler.php).
Proposed resolution
In src/AmazonSesHandler.php, in the method getIdentities(), there's a line that grabs the DKIM attributes using:
$attributes = $result['DkimAttributes'];
The attributes array has a key of SigningEnabled which is a boolean. Either that, or a check if the Tokens key exists should be done.
if ($domain && isset($attributes['Tokens'])) {
$item['token'] = reset($attributes['Tokens']);
}
This stops the fatal error, however a warning is then raised:
Warning: Undefined array key "token" in Drupal\amazon_ses\Form\AmazonSesIdentitiesForm->buildForm() (line 51 of modules/contrib/amazon_ses/src/Form/AmazonSesIdentitiesForm.php).
I haven't had a chance to dive deeper yet, unfortunately
Remaining tasks
Determine if this is the best path in the first place, or if something else needs to be done instead.