Skip to content

[5.x]: craft project-config/apply fails with Undefined array key "name" when updating gateway orderCondition #4185

@romainpoirier

Description

@romainpoirier

What happened?

Description

When updating Craft Commerce from 5.3.13 to 5.5.0 on a development environment using a production database, ./craft project-config/apply fails with:

error: Undefined array key "name"

The error happens while applying project config changes for one specific gateway, right after removing its orderCondition key. It looks related to the new orderCondition handling and the m251112_120000_fix_null_gateway_order_condition migration that was added in the commit fixing #4172.

Relevant log output:

Applying changes from your project config files ...
- removing commerce.gateways.ef65f7cc-2da0-4689-84da-9e3dd33f23ce.orderCondition ...
  - updating commerce.gateways.ef65f7cc-2da0-4689-84da-9e3dd33f23ce ...
error: Undefined array key "name"

The gateway referenced here corresponds to the project config file:

config/project/commerce/gateways/ef65f7cc-2da0-4689-84da-9e3dd33f23ce.yaml

There are no manual edits to this file beyond what the Control Panel and project config normally generate.


Steps to reproduce

  1. Start from a project running Craft Commerce 5.3.13 with project config enabled and at least one payment gateway configured (the one with UID ef65f7cc-2da0-4689-84da-9e3dd33f23ce in my case).

  2. Take a copy of the production database and restore it to a local/development environment.

  3. Update craftcms/commerce in composer.json from 5.3.13 to 5.5.0, then run:

    composer update craftcms/commerce
    ./craft migrate/all
  4. Run:

    ./craft project-config/apply
  5. Observe that the command stops with:

    - removing commerce.gateways.ef65f7cc-2da0-4689-84da-9e3dd33f23ce.orderCondition ...
      - updating commerce.gateways.ef65f7cc-2da0-4689-84da-9e3dd33f23ce ...
    error: Undefined array key "name"
    

Expected behavior

  • ./craft project-config/apply should complete successfully after the Commerce update.
  • The gateway’s orderCondition should be migrated/normalized correctly (including the case where it was previously null or missing), without triggering PHP warnings or errors.
  • Existing gateways should continue to work and be editable in the Control Panel.

Actual behavior

  • ./craft project-config/apply fails with error: Undefined array key "name" while applying config for the gateway ef65f7cc-2da0-4689-84da-9e3dd33f23ce.
  • Project config changes can’t be fully applied, so the instance is effectively stuck until the error is resolved.
  • The error message points to an internal assumption that a name key exists in the gateway config array during project-config handling / migration of the orderCondition.

Note: The stack trace does not provide any additional information.

Craft CMS version

5.8.20

Craft Commerce version

5.5.0

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions