Skip to content
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

[9.x] bug fix, change array_merge to array_replace to prevent reindex #45309

Merged
merged 1 commit into from Dec 14, 2022
Merged

Conversation

kevindees
Copy link
Contributor

Fixes issue where array [506 => null, 'name' => 'kevin'] is reindexed as [0 => null, 'name' => 'kevin']

Fixes issue where array [506 => null, 'name' => 'kevin'] is reindexed as [0 => null, 'name' => 'kevin']
@kevindees
Copy link
Contributor Author

This fix does not provide any new functionality. The primary purpose is to prevent confusion when a database column has a numeric value that will be reindexed by PHP's array_merge. Adds:

  1. Quality of life.
  2. Removes unexpected/buggy behavior.

Example, previous behavior: array [506 => null, 'name' => 'kevin'] is reindexed as [0 => null, 'name' => 'kevin']. New behavior, array [506 => null, 'name' => 'kevin'] results in [506 => null, 'name' => 'kevin'].

@kevindees kevindees changed the title change array_merge to array_replace to prevent reindex [9.*] bug fix, change array_merge to array_replace to prevent reindex Dec 14, 2022
@kevindees kevindees changed the title [9.*] bug fix, change array_merge to array_replace to prevent reindex [9.x] bug fix, change array_merge to array_replace to prevent reindex Dec 14, 2022
@kevindees kevindees changed the title [9.x] bug fix, change array_merge to array_replace to prevent reindex [9.x] bug fix, change array_merge to array_replace to prevent reindex Dec 14, 2022
@taylorotwell
Copy link
Member

Hey there - so your problem is caused by having a column in your database with a purely numeric name? Is that correct?

@kevindees
Copy link
Contributor Author

kevindees commented Dec 14, 2022

@taylorotwell

That is correct. I know numeric names are not accessible at the object level, but our legacy DB uses a numeric column name. If anything removing the reindex allows the issue to bubble to a more user-land-accessible level.

@taylorotwell taylorotwell merged commit 442626c into laravel:9.x Dec 14, 2022
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.

None yet

2 participants