Skip to content

[5.x]: Applying project config on a clean install can fail with undefined array key "type" #18720

@wvell

Description

@wvell

What happened?

Description

Applying project config on a clean install can fail because pending config changes are sorted only by path depth. This can cause sections changes to be processed before related elementSources entries are fully constructed.

When that happens, section change handlers can read a partially-built elementSources config entry that contains nested values like defaultSort and tableAttributes, but is still missing scalar keys such as type. That results in:

Steps to reproduce

  1. See the linked pr test

Expected behavior

Project config should apply successfully on a clean install, without section change handlers observing partially-built elementSources configs.

Actual behavior

Project config application can fail on a clean install or fresh test database with:

In ElementSources.php line 147:

Undefined array key "type"

Craft CMS version

Craft CMS 5.9.17 (and bove)

PHP version

Operating system and version

Database type and version

Image driver and version

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions