magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Disabling async email sending using cli when pending emails in queue causes an error #17673

Open hostep opened 6 years ago

hostep commented 6 years ago

Preconditions

  1. Magento 2.2.5
  2. PHP 7.0.31

Steps to reproduce

  1. Make sure no cronjobs are active
  2. Setup a clean Magento 2.2.5 installation (using composer)
  3. Run bin/magento config:set sales_email/general/async_sending 1
  4. In the backend, create a product
  5. Flush caches
  6. In the frontend, put the created product in your shopping cart, and go through the checkout so you have an order
  7. Since async sales emails sending is enabled, there is now one email in the queue to be send
  8. Now disable async sending, which will also trigger that the pending emails get send: bin/magento config:set sales_email/general/async_sending 0

Expected result

  1. Pending emails get send
  2. Async setting gets disabled
  3. No errors

Actual result

  1. No pending emails get send
  2. Async setting doesn't get disabled
  3. See error: Required parameter 'theme_dir' was not passed

Additional

  1. I'm pretty convinced this used to work in an earlier version of Magento, but will have to do some more testing to see exactly where it worked and where it got broken.
  2. Stack trace, should this be helpful:
    #0  Magento\Framework\View\Design\Fallback\Rule\Simple->getPatternDirs() called at [vendor/magento/framework/View/Design/Fallback/Rule/Theme.php:78]
    #1  Magento\Framework\View\Design\Fallback\Rule\Theme->getPatternDirs() called at [vendor/magento/framework/View/Design/Fallback/Rule/Composite.php:48]
    #2  Magento\Framework\View\Design\Fallback\Rule\Composite->getPatternDirs() called at [vendor/magento/framework/View/Design/Fallback/Rule/ModularSwitch.php:50]
    #3  Magento\Framework\View\Design\Fallback\Rule\ModularSwitch->getPatternDirs() called at [vendor/magento/framework/View/Design/FileResolution/Fallback/Resolver/Simple.php:124]
    #4  Magento\Framework\View\Design\FileResolution\Fallback\Resolver\Simple->resolveFile() called at [vendor/magento/framework/View/Design/FileResolution/Fallback/Resolver/Simple.php:66]
    #5  Magento\Framework\View\Design\FileResolution\Fallback\Resolver\Simple->resolve() called at [vendor/magento/framework/View/Design/FileResolution/Fallback/File.php:42]
    #6  Magento\Framework\View\Design\FileResolution\Fallback\File->getFile() called at [vendor/magento/framework/View/Design/FileResolution/Fallback/TemplateFile.php:82]
    #7  Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile->getFile() called at [vendor/magento/framework/View/FileSystem.php:125]
    #8  Magento\Framework\View\FileSystem->getTemplateFileName() called at [vendor/magento/framework/View/Element/Template/File/Resolver.php:61]
    #9  Magento\Framework\View\Element\Template\File\Resolver->getTemplateFileName() called at [vendor/magento/framework/View/Element/Template.php:221]
    #10 Magento\Framework\View\Element\Template->getTemplateFile() called at [vendor/magento/framework/View/Element/Template.php:300]
    #11 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:667]
    #12 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/module-payment/Helper/Data.php:218]
    #13 Magento\Payment\Helper\Data->getInfoBlockHtml() called at [generated/code/Magento/Payment/Helper/Data/Interceptor.php:76]
    #14 Magento\Payment\Helper\Data\Interceptor->getInfoBlockHtml() called at [vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php:155]
    #15 Magento\Sales\Model\Order\Email\Sender\OrderSender->getPaymentHtml() called at [vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php:128]
    #16 Magento\Sales\Model\Order\Email\Sender\OrderSender->prepareTemplate() called at [vendor/magento/module-sales/Model/Order/Email/Sender.php:77]
    #17 Magento\Sales\Model\Order\Email\Sender->checkAndSend() called at [vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php:102]
    #18 Magento\Sales\Model\Order\Email\Sender\OrderSender->send() called at [vendor/magento/module-sales/Model/EmailSenderHandler.php:74]
    #19 Magento\Sales\Model\EmailSenderHandler->sendEmails() called at [vendor/magento/module-sales/Observer/Virtual/SendEmails.php:50]
    #20 Magento\Sales\Observer\Virtual\SendEmails->execute() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:72]
    #21 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:60]
    #22 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() called at [vendor/magento/framework/Event/Manager.php:66]
    #23 Magento\Framework\Event\Manager->dispatch() called at [generated/code/Magento/Framework/Event/Manager/Proxy.php:95]
    #24 Magento\Framework\Event\Manager\Proxy->dispatch() called at [vendor/magento/module-sales/Model/Config/Backend/Email/AsyncSending.php:32]
    #25 Magento\Sales\Model\Config\Backend\Email\AsyncSending->afterSave() called at [vendor/magento/framework/Interception/Interceptor.php:58]
    #26 Magento\Sales\Model\Config\Backend\Email\AsyncSending\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
    #27 Magento\Sales\Model\Config\Backend\Email\AsyncSending\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
    #28 Magento\Sales\Model\Config\Backend\Email\AsyncSending\Interceptor->___callPlugins() called at [generated/code/Magento/Sales/Model/Config/Backend/Email/AsyncSending/Interceptor.php:26]
    #29 Magento\Sales\Model\Config\Backend\Email\AsyncSending\Interceptor->afterSave() called at [vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:832]
    #30 Magento\Framework\Model\ResourceModel\Db\AbstractDb->processAfterSaves() called at [vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:418]
    #31 Magento\Framework\Model\ResourceModel\Db\AbstractDb->save() called at [vendor/magento/module-config/Console/Command/ConfigSet/DefaultProcessor.php:85]
    #32 Magento\Config\Console\Command\ConfigSet\DefaultProcessor->process() called at [vendor/magento/module-config/Console/Command/ConfigSet/ProcessorFacade.php:156]
    #33 Magento\Config\Console\Command\ConfigSet\ProcessorFacade->processWithLockTarget() called at [vendor/magento/module-config/Console/Command/ConfigSetCommand.php:182]
    #34 Magento\Config\Console\Command\ConfigSetCommand->Magento\Config\Console\Command\{closure}()
    #35 call_user_func_array() called at [vendor/magento/module-config/Console/Command/EmulatedAdminhtmlAreaProcessor.php:59]
    #36 Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor->Magento\Config\Console\Command\{closure}()
    #37 call_user_func_array() called at [vendor/magento/framework/App/State.php:186]
    #38 Magento\Framework\App\State->emulateAreaCode() called at [vendor/magento/module-config/Console/Command/EmulatedAdminhtmlAreaProcessor.php:60]
    #39 Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor->process() called at [vendor/magento/module-config/Console/Command/ConfigSetCommand.php:184]
    #40 Magento\Config\Console\Command\ConfigSetCommand->execute() called at [vendor/symfony/console/Command/Command.php:241]
    #41 Symfony\Component\Console\Command\Command->run() called at [vendor/symfony/console/Application.php:843]
    #42 Symfony\Component\Console\Application->doRunCommand() called at [vendor/symfony/console/Application.php:193]
    #43 Symfony\Component\Console\Application->doRun() called at [vendor/magento/framework/Console/Cli.php:104]
    #44 Magento\Framework\Console\Cli->doRun() called at [vendor/symfony/console/Application.php:117]
    #45 Symfony\Component\Console\Application->run() called at [bin/magento:23]
magento-engcom-team commented 6 years ago

Hi @hostep. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +). For more details, please, review the Magento Contributor Assistant documentation.

@hostep do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

hostep commented 6 years ago

Small update here, this apparently never worked in any Magento version in contrast to what I thought earlier. Since the config:set command was only introduced in Magento 2.2.0, I tested that version, and the same problem occurs there.

I already tried applying the fix from https://github.com/magento/magento2/pull/17344 (since that sounds very related), but that doesn't fix it unfortunately.

ghost commented 6 years ago

@hostep , thank you for your report. We've acknowledged the issue and added to our backlog.

dnsv commented 6 years ago

Hi @hostep. I've reproduced the issue locally, then applied my changes from #17344 which fixed the issue for me. I've tested this using 2.2.5 and the latest 2.2-develop with magento's sample data.

hostep commented 6 years ago

Thanks very much for testing @dnsv!

I just re-tested and at first I couldn't see it being fixed with your PR.

But I noticed that under Content > Design > Configuration, there was no theme set yet, and that is apparently also needed for a fix, so I've configured 'Magento Luma' as the theme.

After doing that and re-running bin/magento config:set sales_email/general/async_sending 0, it now threw a different error: Missing required argument $debugHintsPath of Magento\Developer\Model\TemplateEngine\Plugin\DebugHints.

This error recently got fixed in https://github.com/magento/magento2/pull/17984, so I've applied that patch as well, and now after your patch and this patch and running bin/magento config:set sales_email/general/async_sending 0, it finally works! This was tested on Magento 2.2.6, so it might be slightly different then your test on Magento 2.2.5.

As an extra check, to make sure PR https://github.com/magento/magento2/pull/17984 wasn't the only fix I needed, I re-did the test and only applied https://github.com/magento/magento2/pull/17984 first. After doing that, I was surprised to see that bin/magento config:set sales_email/general/async_sending 0 did actually work and didn't threw any errors, but when verifying if the email got send, it didn't. So I still needed the fix from PR #17344 to have the email getting send as well.

So summary, to be able to fix the bug reported in this issue on Magento 2.2.6:

I feel like it should also work when no theme is configured as it should fall back to the default one (Magento Luma), so that is probably some other small bug somewhere. But in theory, all production environments will most likely have a theme configured properly, so this is a less important bug.

I'll leave this issue open for now, since none of the two PR's mentioned above are merged yet.

dnsv commented 6 years ago

Interesting, I didn't get the $debugHintsPath error, but great to hear that it worked!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

hostep commented 3 years ago

I'm going through a backlog of email alerts from github and found out this issue got closed for no good reason.

So to double check, I tried the same scenario again on the latest 2.4-develop branch (using commit ab591597f860fdee5572d3894c649100e42d884c) and I can still exactly reproduce the problem.

So the issue shouldn't have been closed.

/cc @sdzhepa, @sidolov: can this ticket be reopened please?

m2-assistant[bot] commented 9 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 9 months ago

Hello @hostep,

Thank you for the report and collaboration!

Checked this issue on 2.4-develop, the issue is still present. After setting bin/magento config:set sales_email/general/async_sending 0 we got the error Required parameter 'theme_dir' was not passed. Hence issue can be confirmed.

Thank you.

github-jira-sync-bot commented 9 months ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 9 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10964 is successfully created for this GitHub issue.

m2-assistant[bot] commented 9 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.