Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
kevindees:9.x
Dec 14, 2022
Merged

[9.x] bug fix, change array_merge to array_replace to prevent reindex#45309
taylorotwell merged 1 commit into
laravel:9.xfrom
kevindees:9.x

Conversation

@kevindees

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@kevindees

kevindees commented Dec 14, 2022

Copy link
Copy Markdown
Contributor Author

@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.

2 participants