It would appear that commerce checkout calls for the pane form regardless of whether it declares itself as visible or not in CheckoutPaneInterface::isVisible() We access $this->order->shipments in building the pane form, assuming it is there, but if there is no shipment (and we shouldn't be showing the pane anyway) we get a fatal error. I'm not sure if this should be fixed here, or if it should be fixed in commerce_checkout.

Comments

mikeNCM created an issue. See original summary.

bojanz’s picture

Title: PHP Fatal error: Call to a member function referencedEntities() on null in src/Plugin/Commerce/CheckoutPane/ShippingInformation.php on line 327 » CheckoutFlowWithPanesBase::buildForm() should skip non-visible panes
Project: Commerce Shipping » Commerce Core
Component: Code » Checkout

No point in building a pane we're not going to show, we're just wasting resources.
Let's fix it in Commerce. Stop doing the #access trick.

mikelutz’s picture

Here is a quick fix, and I believe the correct one.

bojanz’s picture

That breaks the API in several places, getPanes() is a public method that's used in many different contexts, including admin settings and declaring config dependencies.

Our fix needs to be in buildForm() / validateForm() / submitForm().
Committed a fix to GitHub, let's see what Travis says: https://travis-ci.org/drupalcommerce/commerce/jobs/198075368

  • bojanz committed 2c6fe2d on 8.x-2.x
    Issue #2849523 by mikeNCM: CheckoutFlowWithPanesBase::buildForm() should...
bojanz’s picture

Status: Active » Fixed

Here we go.

mikelutz’s picture

My mistake, I didn't think that through. Thanks for the quick fix.

mikelutz’s picture

Status: Fixed » Closed (fixed)

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