Skip to content

Fix null address handling and prevent warnings in CustomerProfileWrapper and ColissimoRelayProfile

This merge request fixes a fatal error and related PHP warnings that occur when the customer profile has no address field or when the field is empty during checkout.

Error message example:

Error: Call to a member function getValue() on null in
Drupal\commerce_shipping_colissimo\CustomerProfileWrapper->getAddress()
(line 42 of modules/contrib/commerce_shipping_colissimo/src/CustomerProfileWrapper.php)

Changes

  • Added null checks and field existence validation in CustomerProfileWrapper.
  • Ensured that address fields are only accessed or set when available.
  • Updated ColissimoRelayProfile to use safe default values (?? '') for hidden address form fields.
  • Prevented PHP notices and warnings during checkout when no address is defined.

Testing

Steps to reproduce before the patch:

  1. Install Drupal 10 with Commerce 3.x.
  2. Enable the Commerce Shipping Colissimo module.
  3. Start checkout without a saved address.
  4. Observe fatal error or PHP warnings in logs.

After applying the patch:

  • Checkout works correctly, even when no address is yet defined.
  • No more PHP warnings or fatal errors.

Compatibility

  • Tested on Drupal 10.3 + Commerce 3.3.
  • Compatible with PHP 7.4+.
  • No API or data model changes.
Edited by devator

Merge request reports

Loading