Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Configuration files are loaded incorrectly #2

Open
SAMERkab opened this issue Aug 19, 2021 · 0 comments
Open

Configuration files are loaded incorrectly #2

SAMERkab opened this issue Aug 19, 2021 · 0 comments

Comments

@SAMERkab
Copy link

Configuration data is incorrectly saved in the $config array in loadConfiguration() due to wrong use of array_merge_recursive(). array_merge_recursive() combines a set of arrays into one array by copying all entries from the input arrays into the result array. When two entries have identical keys, an array of the values of both entries is created and assigned to that key in the result array.

private function loadConfiguration(array $searchPaths)
    {
        $config = [];
        foreach ($searchPaths as $file) {
            if (file_exists($file) && is_readable($file)) {
                $config = array_merge_recursive($config, $this->loadConfigurationFromFile($file));
            }
        }

        $this->gitlabUrl = $config['gitlab_url'];
        $this->gitlabUserUsername = $config['gitlab_user_username'];
        $this->gitlabUserEmail = $config['gitlab_user_email'];
        $this->gitlabAuthToken = $config['gitlab_auth_token'];
    }

Solution: Use array_merge() instead of array_merge_recursive().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant