Currently checkout fails when the Editor module is enabled.

TypeError: Argument 1 passed to _editor_get_file_uuids_by_field() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in /var/platform/web/core/modules/editor/editor.module

This is because we invoke \Drupal\commerce_cart\CartProvider::finalizeCart which defaults to saving the cart. However, this save is running within another save. It is causing the ->original property to get popped off, making update hooks and events fail.

We need to check if the original flag is set when invoking the service in commerce_cart_commerce_order_presave

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

We should also follow up to try and get a isSaving method on content entities. Config has isSyncing, so why not check much more easily if content is saving.

mglaman’s picture

Here is the fix.

-      \Drupal::service('commerce_cart.cart_provider')->finalizeCart($order);
+      \Drupal::service('commerce_cart.cart_provider')->finalizeCart($order, !isset($order->original));
mglaman’s picture

mglaman’s picture

Status: Active » Needs review
mglaman’s picture

Need to update patch because Travis still failed. But at least error was reproduced in Travis: https://travis-ci.org/drupalcommerce/commerce/jobs/163272451

1208.29s$ drupal-ti script
PHPUnit 4.8.11 by Sebastian Bergmann and contributors.
......................E........................................  63 / 170 ( 37%)
............................................................... 126 / 170 ( 74%)
................F...........................
Time: 20.13 minutes, Memory: 14.00Mb
There was 1 error:
1) Drupal\Tests\commerce_checkout\Functional\CheckoutOrderTest::testGuestOrderCheckout
Exception: TypeError: Argument 1 passed to _editor_get_file_uuids_by_field() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in /home/travis/build/drupalcommerce/drupal-8/drupal/core/modules/editor/editor.module on line 381
_editor_get_file_uuids_by_field()() (Line: 479)

mglaman’s picture

New patch

  • bojanz committed 6602c62 on 8.x-2.x authored by mglaman
    Issue #2807567 by mglaman: Checkout fails when Editor module enabled (#...
bojanz’s picture

Status: Needs review » Fixed

Merged.

Status: Fixed » Closed (fixed)

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