Problem/Motivation

The template preprocess function currently does this:

function template_preprocess_symfony_mailer_lite_email(&$variables) {
  $variables['base_url'] = $GLOBALS['base_url'];
  $variables['subject'] = $variables['message']['subject'];
  $variables['body'] = $variables['message']['body'];
  $variables['attributes'] = new Attribute();
}

If any module implements a hook_preprocess(), and accesses `$variables['attributes']['class]` or any other typical key, they will get a stack trace similar to the below. This specifically is with bootstrap_barrio, which attmempts to do this:

function bootstrap_barrio_preprocess(&$variables, $hook) {
  if (isset($variables['attributes']['class'])) {
    $class = 'is-invalid';

Not clear on why this is being declared as a new Attribute(), but it likely was meant to be \Drupal\Core\Template\Attribute, not \Attribute.

I don't actually see any references to this in the module code, so the line could also simply be removed.

The website encountered an unexpected error. Please try again later.
Error: Cannot use object of type Attribute as array in bootstrap_barrio_preprocess() (line 790 of themes/contrib/bootstrap_barrio/bootstrap_barrio.theme).
bootstrap_barrio_preprocess(Array, 'symfony_mailer_lite_email', Array)
call_user_func_array('bootstrap_barrio_preprocess', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('symfony_mailer_lite_email', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 160)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 159)
Drupal\Core\Render\Renderer->renderPlain(Array) (Line: 648)
Drupal\symfony_mailer_lite\Plugin\Mail\SymfonyMailer->massageMessageBody(Array, 1) (Line: 205)
Drupal\symfony_mailer_lite\Plugin\Mail\SymfonyMailer->format(Array) (Line: 43)
Drupal\mailsystem\Adapter->format(Array) (Line: 289)
Drupal\Core\Mail\MailManager->doMail('symfony_mailer_lite', 'test', 'test@example.com', 'en', Array, NULL, 1) (Line: 180)
Drupal\Core\Mail\MailManager->Drupal\Core\Mail\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 179)
Drupal\Core\Mail\MailManager->mail('symfony_mailer_lite', 'test', 'test@ example.com', 'en', Array, NULL, 1) (Line: 70)
Drupal\mailsystem\MailsystemManager->mail('symfony_mailer_lite', 'test', 'test@ example.com', 'en') (Line: 85)
Drupal\symfony_mailer_lite\Form\TestEmailForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('symfony_mailer_lite_test_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 68)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

tomtech created an issue. See original summary.

tomtech’s picture

Issue summary: View changes

  • zengenuity committed d26e8c59 on 2.0.x
    fix: #3587220 Attribute class with no namespace causes WSOD when...
zengenuity’s picture

Status: Active » Fixed

Thanks for your detailed report. The attributes are used in the template file, so we can't remove it. Instead, I added a use statement to the module file.

Committed to 2.0.x branch.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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