Skip to content

[5.0] Config arrays incorrectly merged #6088

@rikh42

Description

@rikh42

Steps.

  1. Install a package with config
  2. Publish the config to your app config.
  3. When Laravel attempts to merge the config from the original package settings, with the settings found in your app, some elements are appended instead of being replaced.

Update: Looks like the same problem happens when merging environment specific config over the base config. Basically, config_merge() behaves very differently from array_merge() that was used before. The new behaviour does not appear to be correct

For example.
Config in package

return [
    'enabled' => [
        'first',
        'second'
    ]
]

Published (and edited) config from your apps config/packages/vendorname/packagename

return [
    'enabled' => [
        'alpha',
        'beta'
    ]
]

Expected array when you fetch 'enabled' from the config...

return [
    'enabled' => [
        'alpha',
        'beta'
    ]
]

Actual array you get when you fetch 'enabled' from the config

return [
    'enabled' => [
        'first',
        'second'
        'alpha',
        'beta'
    ]
]

Notice that the items in the 'enabled' array are appended. This appears to happen in config_merge() and differs from 4.2. It only effects config items that contain an array with a numeric index.

This was fine about a week ago. I think it relates to this commit...
5122ea0

I noticed this problem using the package rcrowe/twigbridge. It's extensions.php config file means you can no longer remove packages you don't want, only add additional packages to those declared in the default package config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions