File tree 2 files changed +10
-7
lines changed
2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
All notable changes to this project will be documented in this file.
3
3
4
- ## [ 4.3.0] - unreleased
4
+ ## [ 4.3.1]
5
+
6
+ * Fix memory leak when filling nested fields using dot notation by @GromNaN in [ #2962 ] ( https://github.com/mongodb/laravel-mongodb/pull/2962 )
7
+
8
+ ## [ 4.3.0] - 2024-04-26
5
9
6
10
* New aggregation pipeline builder by @GromNaN in [ #2738 ] ( https://github.com/mongodb/laravel-mongodb/pull/2738 )
7
11
* Drop support for Composer 1.x by @GromNaN in [ #2784 ] ( https://github.com/mongodb/laravel-mongodb/pull/2784 )
Original file line number Diff line number Diff line change 46
46
use function str_contains ;
47
47
use function str_starts_with ;
48
48
use function strcmp ;
49
- use function uniqid ;
50
49
use function var_export ;
51
50
52
51
/** @mixin Builder */
@@ -55,6 +54,8 @@ abstract class Model extends BaseModel
55
54
use HybridRelations;
56
55
use EmbedsRelations;
57
56
57
+ private const TEMPORARY_KEY = '__LARAVEL_TEMPORARY_KEY__ ' ;
58
+
58
59
/**
59
60
* The collection associated with the model.
60
61
*
@@ -271,12 +272,10 @@ public function setAttribute($key, $value)
271
272
// Support keys in dot notation.
272
273
if (str_contains ($ key , '. ' )) {
273
274
// 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 );
277
276
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 ], $ uniqueKey );
280
279
281
280
return $ this ;
282
281
}
You can’t perform that action at this time.
0 commit comments