- Issue created by @nicxvan
- Assigned to abhishek_virasat
- Issue was unassigned.
- Status changed to Needs review
9 months ago 10:09am 15 March 2024 - last update
9 months ago 53 pass, 1 fail The last submitted patch, 3: google_tag-3424695.patch, failed testing. View results →
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- 🇺🇸United States nicxvan
Is there any chance you can put that into a merge request?
I did some local testing I have not pushed up yet and I think there is a simpler fix where we assert the order is an Drupal\commerce_order\Entity\OrderInterface rather than just asserting it is !null.
- 🇩🇪Germany Anybody Porta Westfalica
I think this should be checked and solved in combination with the other commerce related issues?
- 🇺🇸United States nicxvan
I haven't been able to test this on my client yet, but just looking at the code this is not fixed:
https://git.drupalcode.org/project/google_tag/-/blob/2.0.x/src/Plugin/Go...
That line is what throws the error and there are no new protections.
I think the patch does quite a bit more than needed, I think we just need to call:
$order_item->getOrder()
then assert that it's an OrderInterface before moving on.Nominally this patch seems to do the same, but rather than just exiting they try to pass as much info as exists.
I think if the event is incomplete not sending the event is probably better, let me know which direction you would like to go.
- 🇺🇸United States nicxvan
Pushing a quick assertion as POC. I still need to review tests.
I'm hiding the patch since it seems to make a lot of unnecessary changes.
- last update
9 months ago 54 pass - 🇯🇴Jordan Ahmad Khader
I'm having a similar issue but assert already exists there
The website encountered an unexpected error. Please try again later. Error: Call to a member function subtract() on null in Drupal\google_tag\Plugin\GoogleTag\Event\Commerce\AddToCartEvent->getData() (line 44 of modules/contrib/google_tag/src/Plugin/GoogleTag/Event/Commerce/AddToCartEvent.php). Drupal\google_tag\Plugin\GoogleTag\Event\Commerce\AddToCartEvent->getData() (Line: 147) google_tag_page_attachments(Array) (Line: 315) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}(Object, 'google_tag') (Line: 405) Drupal\Core\Extension\ModuleHandler->invokeAllWith('page_attachments', Object) (Line: 316) Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 289) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 290) Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) call_user_func(Array, Object, 'kernel.view', Object) (Line: 142) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81) 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: 718) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
- 🇯🇴Jordan rahaf albawab Amman
I'm facing the same issue in the AddToCartEvent class. I rolled back the fix in the merge request and applied the same changes to AddToCartEvent
- 🇺🇸United States nicxvan
If there is an existing MR please apply your changes to the MR.
Technically those changes are out of scope of this issue since it's a different event. If you want to increase the scope please update the Issue summary and review this issue so we can get it merged.
Regarding comment #10, I had the same issue when handling order items for which the price was not calculated yet, so I created issue #3489811 🐛 AddToCartEvent WSOD for order items with no price Active