Skip to content

[12.x] Correct how base options for missing config files are preloaded #56198

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

Closed
wants to merge 3 commits into from

Conversation

u01jmg3
Copy link
Contributor

@u01jmg3 u01jmg3 commented Jul 2, 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 2, 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 force-pushed the 12.x branch 3 times, most recently from 16004f7 to 8a31870 Compare July 4, 2025 19:18
@u01jmg3 u01jmg3 force-pushed the 12.x branch 2 times, most recently from 326f227 to 0be38f9 Compare July 4, 2025 19:44
@u01jmg3 u01jmg3 changed the title Correct how base options for missing config files are preloaded [12.x] Correct how base options for missing config files are preloaded Jul 4, 2025
@u01jmg3 u01jmg3 closed this Jul 4, 2025
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.

1 participant