Skip to content

Commit cb84a43

Browse files
Merge 4.3 into 4.4 (#2963)
2 parents 8dcb1a0 + 3db44cd commit cb84a43

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
88
* Rename queue option `table` to `collection`
99
* Replace queue option `expire` with `retry_after`
1010

11+
## [4.3.1]
12+
13+
* Fix memory leak when filling nested fields using dot notation by @GromNaN in [#2962](https://github.com/mongodb/laravel-mongodb/pull/2962)
14+
1115
## [4.3.0] - 2024-04-26
1216

1317
* New aggregation pipeline builder by @GromNaN in [#2738](https://github.com/mongodb/laravel-mongodb/pull/2738)

src/Eloquent/Model.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
use function str_contains;
4747
use function str_starts_with;
4848
use function strcmp;
49-
use function uniqid;
5049
use function var_export;
5150

5251
/** @mixin Builder */
@@ -55,6 +54,8 @@ abstract class Model extends BaseModel
5554
use HybridRelations;
5655
use EmbedsRelations;
5756

57+
private const TEMPORARY_KEY = '__LARAVEL_TEMPORARY_KEY__';
58+
5859
/**
5960
* The collection associated with the model.
6061
*
@@ -271,12 +272,10 @@ public function setAttribute($key, $value)
271272
// Support keys in dot notation.
272273
if (str_contains($key, '.')) {
273274
// Store to a temporary key, then move data to the actual key
274-
$uniqueKey = uniqid($key);
275-
276-
parent::setAttribute($uniqueKey, $value);
275+
parent::setAttribute(self::TEMPORARY_KEY, $value);
277276

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

281280
return $this;
282281
}

0 commit comments

Comments
 (0)