Skip to content

Merge 4.3 into 4.4 #2963

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 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
* Rename queue option `table` to `collection`
* Replace queue option `expire` with `retry_after`

## [4.3.1]

* Fix memory leak when filling nested fields using dot notation by @GromNaN in [#2962](https://github.com/mongodb/laravel-mongodb/pull/2962)

## [4.3.0] - 2024-04-26

* New aggregation pipeline builder by @GromNaN in [#2738](https://github.com/mongodb/laravel-mongodb/pull/2738)
Expand Down
11 changes: 5 additions & 6 deletions src/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
use function str_contains;
use function str_starts_with;
use function strcmp;
use function uniqid;
use function var_export;

/** @mixin Builder */
Expand All @@ -55,6 +54,8 @@ abstract class Model extends BaseModel
use HybridRelations;
use EmbedsRelations;

private const TEMPORARY_KEY = '__LARAVEL_TEMPORARY_KEY__';

/**
* The collection associated with the model.
*
Expand Down Expand Up @@ -271,12 +272,10 @@ public function setAttribute($key, $value)
// Support keys in dot notation.
if (str_contains($key, '.')) {
// Store to a temporary key, then move data to the actual key
$uniqueKey = uniqid($key);

parent::setAttribute($uniqueKey, $value);
parent::setAttribute(self::TEMPORARY_KEY, $value);

Arr::set($this->attributes, $key, $this->attributes[$uniqueKey] ?? null);
unset($this->attributes[$uniqueKey]);
Arr::set($this->attributes, $key, $this->attributes[self::TEMPORARY_KEY] ?? null);
unset($this->attributes[self::TEMPORARY_KEY]);

return $this;
}
Expand Down
Loading