Hello,
Thank you for the developpement of this great module.
I have an issue when I activate "Business Rules" on a D8 Commerce Website.
When I go on a product page (whith an add to cart form), I have this error:
The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\Core\Entity\ContentEntityForm::setFormId() in Drupal\commerce_product\ProductLazyBuilders->addToCartForm() (line 87 of modules/contrib/commerce/modules/product/src/ProductLazyBuilders.php).
There is another module with a similar error (https://www.drupal.org/project/form_mode_manager/issues/2907913).
The complete error:
Error : Call to undefined method Drupal\Core\Entity\ContentEntityForm::setFormId() dans Drupal\commerce_product\ProductLazyBuilders->addToCartForm() (/var/www/drupalvm/drupal/web/modules/contrib/commerce/modules/product/src/ProductLazyBuilders.php ligne 87) #0 [internal function]: Drupal\commerce_product\ProductLazyBuilders->addToCartForm('135', 'full', true, 'fr')
#1 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(358): call_user_func_array(Array, Array)
#2 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, true)
#3 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(151): Drupal\Core\Render\Renderer->render(Array, true)
#4 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#5 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(152): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#6 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->renderPlain(Array)
#7 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(667): Drupal\Core\Render\Renderer->renderPlaceholder('<drupal-render-...', Array)
#8 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(552): Drupal\Core\Render\Renderer->replacePlaceholders(Array)
#9 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, true)
#10 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(139): Drupal\Core\Render\Renderer->render(Array, true)
#11 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#12 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(140): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#13 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(258): Drupal\Core\Render\Renderer->renderRoot(Array)
#14 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(131): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->renderPlaceholders(Object(Drupal\Core\Render\HtmlResponse))
#15 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments(Object(Drupal\Core\Render\HtmlResponse))
#16 [internal function]: Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond(Object(Symfony\Component\HttpKernel\Event\FilterResponseEvent), 'kernel.response', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#17 /var/www/drupalvm/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\FilterResponseEvent), 'kernel.response', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#18 /var/www/drupalvm/drupal/vendor/symfony/http-kernel/HttpKernel.php(191): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.response', Object(Symfony\Component\HttpKernel\Event\FilterResponseEvent))
#19 /var/www/drupalvm/drupal/vendor/symfony/http-kernel/HttpKernel.php(173): Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object(Drupal\Core\Render\HtmlResponse), Object(Symfony\Component\HttpFoundation\Request), 1)
#20 /var/www/drupalvm/drupal/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#21 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/drupalvm/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/drupalvm/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/drupalvm/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(666): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /var/www/drupalvm/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#30 {main}.
When i disable "Business Rules", no more issue.
Any ideas ?
Best regards,
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | business_rules-commerce_add_to_cart_crash-2997487-16.patch | 826 bytes | waspper |
| #11 | business_rules_causing_commerce_add_to_cart_form_crash-2997487.patch | 863 bytes | marko.romsak |
Comments
Comment #2
pyxio commentedsame error for me
Comment #3
idiaz.ronceroSame here. This makes Business_rules unusable with Commerce.
Comment #4
pyxio commentedyes, this module cannot be used on a commerce website. try rules i guess.
Comment #5
bandana commentedSame here, however it worked for some time after I had installed it. Have not been able to reproduce whatever made it work in the first place. How frustrating since this module seemed perfect to solve some features I need in combination with Commerce that currently I cannot make work with Rules either.
Comment #6
pyxio commentedthis issue means business rules cannot be used on commerce sites. that is a significant issue. are there any plans to look into this?
Comment #7
pyxio commentedi tested this on a fresh installation. the page with add to cart does not crash like on my other site however the add to cart button disappears completely. if i uninstall business_rules the button displays again. i checked dblog and here is the full error on a brand new drupal 8.6.3 installation
Error: Call to undefined method Drupal\Core\Entity\ContentEntityForm::setFormId() in Drupal\commerce_product\ProductLazyBuilders->addToCartForm() (line 87 of /var/www/html/beta/web/modules/contrib/commerce/modules/product/src/ProductLazyBuilders.php) #0 [internal function]: Drupal\commerce_product\ProductLazyBuilders->addToCartForm('1', 'full', true, 'en') #1 /var/www/html/beta/web/core/lib/Drupal/Core/Render/Renderer.php(358): call_user_func_array(Array, Array) #2 /var/www/html/beta/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, true) #3 /var/www/html/beta/web/core/lib/Drupal/Core/Render/Renderer.php(151): Drupal\Core\Render\Renderer->render(Array, true) #4 /var/www/html/beta/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() #5 /var/www/html/beta/web/core/lib/Drupal/Core/Render/Renderer.php(152): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #6 /var/www/html/beta/web/core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->renderPlain(Array) #7 /var/www/html/beta/web/core/modules/big_pipe/src/Render/BigPipe.php(696): Drupal\Core\Render\Renderer->renderPlaceholder('callback=commer...', Array) #8 /var/www/html/beta/web/core/modules/big_pipe/src/Render/BigPipe.php(550): Drupal\big_pipe\Render\BigPipe->renderPlaceholder('callback=commer...', Array) #9 /var/www/html/beta/web/core/modules/big_pipe/src/Render/BigPipe.php(305): Drupal\big_pipe\Render\BigPipe->sendPlaceholders(Array, Array, Object(Drupal\Core\Asset\AttachedAssets)) #10 /var/www/html/beta/web/core/modules/big_pipe/src/Render/BigPipeResponse.php(112): Drupal\big_pipe\Render\BigPipe->sendContent(Object(Drupal\big_pipe\Render\BigPipeResponse)) #11 /var/www/html/beta/vendor/symfony/http-foundation/Response.php(374): Drupal\big_pipe\Render\BigPipeResponse->sendContent() #12 /var/www/html/beta/web/index.php(20): Symfony\Component\HttpFoundation\Response->send() #13 {main}.
Comment #8
pyxio commentedperhaps this is a commerce bug and not related to business rules?
Comment #9
bojanz commentedMarked #3017380: commerce product display crashes when business_rules enabled as a duplicate.
The bug is caused by this Business Rules code:
This swaps the AddToCartForm with the generic entity form, which can't work.
Comment #10
pyxio commented@bojanz thank you for your time and effort.
Comment #11
marko.romsak commentedI have done a quick fix patch just for add to cart form by adding the machine name "add_to_cart".
It works for me so it might help someone else as well.
Comment #12
pyxio commented@marko.romsak where is the patch you made? I want to try it. thanks kevin
Comment #13
mrpeanut commented@pyxio -- There is a link to the patch in the original post. It applied for me but did not fix the issue.
Comment #14
marko.romsak commented@pyxio I don't know what happened with my comment and patch. The patch is in the original post, but the comment is missing.
Comment #15
mrpeanut commentedComment #16
waspper commentedI've refactored a bit previous patch, if needed a quick workaround. It would be nice to have a confirmation if taken approach is right.
@MrPeanut: I tried on a fresh installation, and it worked. No more issue. Did you clear cache after applying patch?
Comment #17
waspper commentedComment #18
pyxio commented#16 works for me. @wassper @marko.romsak thank you guys for fixing this critical issue.
Comment #19
mrpeanut commented@waspper I may not have. Patch from #16 applies and fixes the issue. Thanks to you and @mark.romsak!
Comment #20
Andy-vv commentedHi guys, I am a newbie to drupal and I am not a coder. I try to build my site completely out of the box. I have hit the same "business rules vs. commerce" issue that you have described and solved with the patch. Only trouble for me is that I do not know where to insert the patch! Can someone tell me which file I need to add it into, and if possible where in the file. Many thanks for any help, this issue has blown my development up :(
Comment #21
c.e.a commentedComment #22
mmjvb commentedDue to #19 set Status to RTBC, a signal to the maintainer to adopt the patch or set back to Needs work when not 100% happy.
When accepting the patch, it should be committed and this issue should set to Fixed and remove the assignment. After two weeks it will be automatically set to Fixed (Closed). In which case it needs a maintainer to change Status and it disappears from the open issue list.
Comment #23
c.e.a commentedComment #24
B1 commentedAgreed. Great module.
Drupal: 8.7.4
PHP: 7.2.18
Commerce: 8.x-2.13
Business Rules:8.x-1.x-dev
Same issue.
Applied Patch #16: worked for me.
Much appreciated @waspper.
Hope patch gets committed.
Comment #25
Andy-vv commentedI wonder if anyone in the patch world can give me a bit of advice. I'e been trying to apply the patch no.16 to the excellent business rules module. I can manage it manually and get the change to my local installation of drupal. Trouble is, my overall installation is built with composer, and so what I have done locally will not commit. I have then tried updating my composer.json with the code below. Unfortunately the patch is not being picked up. I think it's something simple but I don't have the experience to spot it!
Any ideas would be welcome!
},
"extra": {
"patchLevel": {
"drupal/core": "-p2",
"patches":{
"drupal/business_rules":{
"commerce cart patch": "https://www.drupal.org/files/issues/2019-01-23/business_rules-commerce_a..."
},
"installer-paths": {
Comment #26
Andy-vv commentedWith a hint or two from folks I managed to solve my issue #25. For the benefit of any other newbies who are not great at editing composer.json files I have put an extract of mine below, with the new code in bold . I have included the blocks above and below the new code so that you can see exactly how the formatting must be made.
"scripts": {
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"patchLevel": {
"drupal/core": "-p2"
},
"patches":{
"drupal/business_rules":{
"commerce cart patch": "https://www.drupal.org/files/issues/2019-01-23/business_rules-commerce_a..."
}
},
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/{$name}": ["type:drupal-drush"]
},
Comment #28
colan@pyxio: Please do not abuse the Priority system. This is not Critical as not everyone's using Commerce. Critical means that the module doesn't work at all, for anyone.
Thanks folks.
Comment #29
mmjvb commented@C.E.A. Could you respond to #28. Consider it inappropriate, but my opinion is not relevant. What is your opinion on downgrading the priority?
And what about the reprimand to @pyxio ? Consider it inappropriate coming from @colan. Coming from you I would still consider it strong language. A simple downgrade to `Major` would be ok, considering it conflicts with Commerce. Surprised about the commit as well, wonder how that is possible. But that is off the record.
Comment #30
colan#29: See Priority levels of issues (and #3074452: Colan request to be maintainer for how I became a maintainer).
Comment #31
rodmarasi commentedChill guys. Its just a correction on the status. Both of you are contributing to this module. Dont let emotion get in the way.
Comment #32
mmjvb commentedIt is not the correction of the status, that is considered normal. It is the way it was corrected. Wasn't aware of @colan taking over. Don't consider this the correct way to convey a change in policy. Of course maintainers are free to change policy. No idea how @pyxio feels about it, but I completely lost interest now.
Comment #34
stuhannaford commentedThe issue appears again when using the module Commerce Product Add-On (PADO), and so have manually updated the code on my site from:
$skip_names = ['register', 'add_to_cart'];to
$skip_names = ['register', 'add_to_cart', 'pado_add_to_cart'];in business_rules.module as a work around.