Skip to content

[11.x] Correct how base options for missing config files are preloaded #56216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025

Conversation

u01jmg3
Copy link
Contributor

@u01jmg3 u01jmg3 commented Jul 4, 2025

Issue introduced by PR #51619 and present since Laravel 11.10


Offending code

foreach (array_diff(array_keys($base), array_keys($files)) as $name => $config) {
$repository->set($name, $config);
}

Given the config

$baseArrayKeys $filesArrayKeys
[
'app',
'auth',
'broadcasting',
'cache',
'concurrency',
'cors',
'database',
'filesystems',
'hashing',
'logging',
'mail',
'queue',
'services',
'session',
'view',
];
[
'app',
'broadcasting',
'cache',
'custom',
'database',
'filesystems',
'logging',
'mail',
'queue',
];

You get

// array_diff(array_keys($base), array_keys($files)

$keysArrayDiff = [
    1 => 'auth',
    4 => 'concurrency',
    5 => 'cors',
    8 => 'hashing',
    12 => 'services',
    13 => 'session',
    14 => 'view',
];
  • This means you're setting a config item with $name = 1 and $config = 'auth', etc. which isn't the intention.
  • Test added to demo the issue/fix

Instead switch to

+use Illuminate\Support\Collection;

-foreach (array_diff(array_keys($base), array_keys($files)) as $name => $config) {
+foreach (Collection::make($base)->diffKeys($files) as $name => $config) {
    $repository->set($name, $config);
}

Copy link

github-actions bot commented Jul 4, 2025

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@u01jmg3 u01jmg3 marked this pull request as ready for review July 4, 2025 20:12
@taylorotwell taylorotwell merged commit 18d3b1b into laravel:11.x Jul 7, 2025
58 checks passed
@u01jmg3 u01jmg3 deleted the 11.x branch July 7, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants