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

PHPORM-184 Use fixed key for temporary setting nested field #2962

Merged
merged 1 commit into from
May 21, 2024

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented May 21, 2024

Fix PHPORM-184
Fix #2959

The memory leak reported in #2959 is caused by the random temporary key used before setting a nested value. There is a cache in Illuminate\Suport\Str::studly that inflate for each random key.

Also, uniqid is slow and not necessary here. The temporary key can be static as there is not risk of conflict/collision.

  • The last operation of parent::setAttribute() is $this->attributes[$key] = $value;
  • Then $this->attributes[$key] is read and wrote in the nested array;
  • Then $this->attributes[$key] is unset.

There is no possibility of a code acting on this key in the meantime.

Checklist

  • Add tests and ensure they pass
  • Add an entry to the CHANGELOG.md file
  • Update documentation for new features

@GromNaN GromNaN added this to the 4.3 milestone May 21, 2024
@GromNaN GromNaN merged commit a7aecf8 into mongodb:4.3 May 21, 2024
24 checks passed
@GromNaN GromNaN deleted the PHPORM-184 branch May 21, 2024 20:51
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