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
taylorotwell pushed a commit that referenced this pull request Jul 14, 2025
* [11.x] Correct how base options for missing config files are preloaded (#56216)

* Formatting

* Add breaking test to demo config array has been incorrectly keyed with numbers

* Correct how base options for missing config files are preloaded

* fix: AsCommand properties not being set on commands (#56236)

The Symfony Command uses the AsCommand attribute to set properties on
the command class. However, the properties are only set if they are
identical to an empty string. The Laravel Command class overrides the
properties and removes the default value which causes the properties to
be null and therefore not set.

---------

Co-authored-by: Caleb White <cdwhite3@pm.me>
mohammad-fouladgar pushed a commit to mohammad-fouladgar/framework that referenced this pull request Jul 22, 2025
* [11.x] Correct how base options for missing config files are preloaded (laravel#56216)

* Formatting

* Add breaking test to demo config array has been incorrectly keyed with numbers

* Correct how base options for missing config files are preloaded

* fix: AsCommand properties not being set on commands (laravel#56236)

The Symfony Command uses the AsCommand attribute to set properties on
the command class. However, the properties are only set if they are
identical to an empty string. The Laravel Command class overrides the
properties and removes the default value which causes the properties to
be null and therefore not set.

---------

Co-authored-by: Caleb White <cdwhite3@pm.me>
crynobone added a commit that referenced this pull request Aug 12, 2025
* [11.x] Correct how base options for missing config files are preloaded (#56216)

* Formatting

* Add breaking test to demo config array has been incorrectly keyed with numbers

* Correct how base options for missing config files are preloaded

* fix: AsCommand properties not being set on commands (#56236)

The Symfony Command uses the AsCommand attribute to set properties on
the command class. However, the properties are only set if they are
identical to an empty string. The Laravel Command class overrides the
properties and removes the default value which causes the properties to
be null and therefore not set.

* update trust proxy

* add trust proxy

* [12.x] Consistent use of `mb_split()` to split strings into words (#56338) (#56617)

* consistent use of mb_split to split strings into words with multi-byte support

* The $pattern argument doesn't use /pattern/ delimiters, unlike other regex functions such as preg_match

Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com>

* fix: CacheSchedulingMutex should use lock connection (#56472) (#56614)

Co-authored-by: Julius van Dijk <julius@anaglyphic.com>

* Test Improvements

- Fix integration with PHPUnit 12.3.4
- Fix PHPStan

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Jonathan Goode <u01jmg3@users.noreply.github.com>
Co-authored-by: Caleb White <cdwhite3@pm.me>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com>
Co-authored-by: Julius van Dijk <julius@anaglyphic.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
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