Problem/Motivation

Thank you Adam for having time to have a big and quick progress on this module.
Testing after each release ...

Only reporting this issue after updating to Symfony Mailer 1.0.0-alpha7

Steps to reproduce

Given that the Symfony Mailer module was installed in a Drupal 9.3.x site
And the Symfony Mailer Back-compatibility module was enabled too
And the Error messages to display was sat to "All messages, with backtrace information"
When navigating to "/admin/config/system/mailer/import"
Then the following notice will show up 3 times

Notice: Undefined index: import in Drupal\symfony_mailer\Processor\EmailBuilderManager->getImportInfo() (line 103 of modules/contrib/symfony_mailer/src/Processor/EmailBuilderManager.php).
Drupal\symfony_mailer\Processor\EmailBuilderManager->getImportInfo() (Line: 59)
Drupal\symfony_mailer\Controller\SymfonyMailerController->importStatus()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->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: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

Have a check for the import index.

Remaining tasks

  • File the issue
  • Fix patch/MR
  • Testing
  • Review
  • Comment
  • Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Rajab Natshah created an issue. See original summary.

rajab natshah’s picture

Issue summary: View changes

rajab natshah’s picture

Assigned: rajab natshah » Unassigned
Status: Active » Needs review
adamps’s picture

Thanks for the testing and bug report. My enthusiasm for this project has been boosted by seeing how many sites are using the module already.

I don't see the warning you report. I think this patch shouldn't be needed because there is code in Drupal\symfony_mailer\Annotation\EmailBuilder to initialise $import = '';.

Please could you try clearing caches and see if that fixes it?

joshahubbers’s picture

I can confirm that I also needed this patch.

I updated a site from Swift mailer to Symphony mailer, following https://www.drupal.org/docs/contributed-modules/symfony-mailer-0/getting....

On the first "import configuration", there was nothing to import.
On the second "import configuration", the error occured.

Drupal 9.3.9

adamps’s picture

Did you both try clearing caches?

Please could you try and get some debug output with code something like this:

diff --git a/src/Processor/EmailBuilderManager.php b/src/Processor/EmailBuilderManager.php
index 842f521..3b5b5fe 100644
--- a/src/Processor/EmailBuilderManager.php
+++ b/src/Processor/EmailBuilderManager.php
@@ -100,6 +100,7 @@ class EmailBuilderManager extends DefaultPluginManager implements EmailBuilderMa
     $state_all = $this->keyValue->get('import', []);
 
     foreach ($this->getDefinitions() as $id => $definition) {
+      ksm($definition);
       if ($definition['import']) {
         $state = $state_all[$id] ?? self::IMPORT_READY;
joshahubbers’s picture

Ik did clear the cache multiple times. That normally solves most of Drupal's problems ;-).

I moved away from this module because after testing, i stumbled upon the unability to mail attachments with webform. So unfortunately I cannot provide more info at this moment. Maybe I will revisit this when attachments are supported. I see a lot of activity in that issue.

steveg.’s picture

After updating to the latest version of Symfony mailer 1.0.0-alpha7 and applying the patch. I don't get any error's and I've tested my mailing and works like it should.

adamps’s picture

Status: Needs review » Postponed (maintainer needs more info)

Thanks for the updates. The problem I have is that I can't reproduce the error, and I can't see why any change is needed, as explained in #5. In #7 I asked if someone could provide some extra debugging. Any help with this would be welcome.

adamps’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new993 bytes

Ha and now I hit it myself😃.

I added a new patch that I prefer because it goes to the source of the problem by fixing the missing array entry (and any other possible future missing entry). Previous patch just worked around the missing entry.

I would appreciate any testing.

adamps’s picture

Title: Fix Notice: Undefined index: import in EmailBuilderManager->getImportInfo() » Undefined index: import in EmailBuilderManager->getImportInfo()
Category: Task » Bug report
Status: Needs review » Fixed

  • AdamPS committed 1e958c0 on 1.x
    Issue #3274819 by Rajab Natshah, AdamPS: Fix Notice: Undefined index:...
rajab natshah’s picture

Issue summary: View changes

Patch in #11 is the better fix from symfony_mailer_bc directly
Thanks Adam, it is the right fix.

Only in case custom modules had a BC functions to import for custom plugins
A throw message with try-catch could be nicer on the import in case of empty imports.


Updated the Steps to reproduce with
Given that the Symfony Mailer module was installed in a Drupal 9.3.x site
And the Symfony Mailer Back-compatibility module was enabled too
And the Error messages to display was sat to "All messages, with backtrace information"
rajab natshah’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

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