- Issue created by @DuttonMa
- Status changed to Postponed: needs info
over 1 year ago 2:44pm 19 April 2023 - πΊπΈUnited States cilefen
The one-line error is not enough go go on. We need more of a stack trace to take this on as a bug report.
- Status changed to Downport
over 1 year ago 2:47pm 19 April 2023 - Status changed to Postponed: needs info
over 1 year ago 4:06pm 19 April 2023 - πΊπΈUnited States cilefen
We still need steps to reproduce to understand why the "to" field is empty.
- last update
over 1 year ago 30,322 pass - π¬π§United Kingdom DuttonMa
Steps to reproduce:
- Fresh install of Drupal 9.5.9
- Create a new user without an email address (yes, Drupal does let you do this !)
- block the user via drush ('drush user:block- unblock the user via drush ('drush user:unblock ')
At this point the following TypeError is thrown:
TypeError: Drupal\Core\Mail\Plugin\Mail\PhpMail::doMail(): Argument #1 ($to) must be of type string, null given, called in /app/web/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php on line 118 in /app/web/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php on line 162 #0 /app/web/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php(118): Drupal\Core\Mail\Plugin\Mail\PhpMail->doMail(NULL, 'Account details...', 'test4,\n\nYour ac...', 'MIME-Version: 1...', '-fadmin@example...')
#1 /app/web/core/lib/Drupal/Core/Mail/MailManager.php(307): Drupal\Core\Mail\Plugin\Mail\PhpMail->mail(Array)
#2 /app/web/core/lib/Drupal/Core/Mail/MailManager.php(180): Drupal\Core\Mail\MailManager->doMail('user', 'status_activate...', NULL, 'en', Array, 'admin@example.c...', true)
#3 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Mail\MailManager->Drupal\Core\Mail\{closure}()
#4 /app/web/core/lib/Drupal/Core/Mail/MailManager.php(181): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#5 /app/web/core/modules/user/user.module(1069): Drupal\Core\Mail\MailManager->mail('user', 'status_activate...', NULL, 'en', Array, 'admin@example.c...')
#6 /app/web/core/modules/user/src/Entity/User.php(139): _user_mail_notify('status_activate...', Object(Drupal\user\Entity\User))
#7 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(597): Drupal\user\Entity\User->postSave(Object(Drupal\user\UserStorage), true)
#8 /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(781): Drupal\Core\Entity\EntityStorageBase->doPostSave(Object(Drupal\user\Entity\User), true)
#9 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(523): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object(Drupal\user\Entity\User), true)
#10 /app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\user\Entity\User))
#11 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\user\Entity\User))
#12 /app/vendor/drush/drush/src/Drupal/Commands/core/UserCommands.php(159): Drupal\Core\Entity\EntityBase->save()
#13 [internal function]: Drush\Drupal\Commands\core\UserCommands->unblock('test4', Array)
#14 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#15 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#16 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#17 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(390): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#18 /app/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /app/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /app/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /app/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /app/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /app/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /app/vendor/drush/drush/drush.php(77): Drush\Runtime\Runtime->run(Array)
#25 /app/vendor/drush/drush/drush(4): require('/app/vendor/dru...')
#26 /app/vendor/bin/drush(120): include('/app/vendor/dru...')
#27 {main} - Status changed to Needs work
over 1 year ago 11:22am 19 May 2023 - πΊπΈUnited States cilefen
Understood. That information would be better placed in the issue summary.
What kind of email is Drupal sending in these cases? Is there really no βtoβ value? What even attempt sending the email?
- Status changed to Needs review
over 1 year ago 11:30am 19 May 2023 - last update
over 1 year ago 30,334 pass - π¬π§United Kingdom DuttonMa
I have put those 'steps to reproduce' in the issue summary as suggested.
In this case no email is sent from Drupal, but an attempt is made to send one. I notice that when you create a user without an email address through the admin screens, Drupal is clever enough to not attempt sending the email even if you click 'notify user' and tells you so. Perhaps the best solution would be to not even attempt to send the email when unblocking the user via drush as well ?
I attach a new patch to fix this issue at the PHP mail level as there was a problem with the first one.
- Status changed to Needs work
over 1 year ago 12:08pm 19 May 2023 - π¬π§United Kingdom DuttonMa
Yes that's what I thought too, the fix in #8 π Exception thrown when unblocking a user via drush Needs work is a temporary one just to stop the exception - I'll work on a better fix further up in the logic
- Status changed to Needs review
over 1 year ago 2:25pm 19 May 2023 - last update
over 1 year ago 30,334 pass - π¬π§United Kingdom DuttonMa
Here is a better patch that doesn't try to send the notification email if the user doesn't have an email address
- Status changed to Needs work
over 1 year ago 3:04pm 19 May 2023 - πΊπΈUnited States smustgrave
Did not test
Sending to NW for the tests.
- πΊπΈUnited States joshua.boltz
I think may be related - https://www.drupal.org/project/smtp/issues/3224734 β
- last update
about 1 year ago 30,341 pass